# Equation of ellipse in 3D

1. Apr 12, 2007

### Klaws

Hi,

I'm writing a visualization tool for magnetic fields in DirectX. I am currently building a model for 3D curves which will be used to describe field lines. The curves will be built as staight pipes joining several points. The lighting and shading will then take care of smoothing things.

Now back to maths. I have two direction vectors describing the direction of two pipes. They join at the origin. Now the part that joins the two pipes needs to be an ellipse at an angle that bisects the two vectors. Knowing the radius of the pipes (equal radius) and the two vectors, is it possible to come up with the equation of the ellipse in 3D? thank you and sorry if this is not so clear.

2. Apr 12, 2007

### christianjb

Define a rotation matrix from your pipe coordinate system to your global coordinate system.

The 3X3 rotation matrix is given by
Axx,Axy,Axz
Ayx,Ayy,Ayz
Azx,Azy,Azz

with elements
A_xy=x'.y, etc. (x'.y is the dot product between x' and y)
where x,y,z are unit vectors in your global coordinate system, and x',y',z' are unit vectors in your pipe coordinate system.

Then define the ellipse in your global coordinate system and use the rotation matrix to transform the ellipse into your pipe coordinate system.

3. Apr 12, 2007

### Klaws

The problem is defining the ellipse in global coordinates. What I was doing to test the pipe building part was defining the ellipse joining two pipes as a circle with radius 1 at the origin with x=0(on yz plane). Now I'd like to 'upgrade' this to an ellipse that joins the pipes.

Thank you for the replies.
Claudio

4. Apr 12, 2007

### christianjb

OK, I'm not sure I understand.

If the pipes were laid completely flat and oriented along convenient x-y directions then you wouldn't have a problem with defining the ellipse right?

5. Apr 12, 2007

### Klaws

Yes that is my problem. Defining the ellipses when the pipes lie on the XY plane. What I want is the equation of the ellipse derived from the two pipes (vectors) and their radius.

Thanks again,

Claudio

6. Apr 12, 2007

### christianjb

OK, so you want to define an ellipse which touches the ends of two vectors in the x-y plane. I suppose that the pipes are not in general at 90 degrees to eachother?

7. Apr 13, 2007

### Klaws

I have 2 unit vectors in the xy plane. I am constructing a pipe around each of these vectors. What I want is the ellipse that is formed at the origin(in 3D) when the two pipes meet. If the pipes are at 90 degrees the ellipse will be at 45 degrees. In general, the pipes are at obtuse angles but not necessarily.

8. Apr 13, 2007

### christianjb

Sorry, maybe I'm being dense here.

I'm still not sure what this pipe is.

There are two axes for the ellipse, at right angles to eachother. How do these two axes depend on the direction of the two vectors?

9. Apr 13, 2007

### Klaws

No problem at all, after all, you're trying to help me out :)

I'm attaching a picture of two pipes. Their vectors are <0,1,0> and <1,1,0>. The ellipse should be the one joining the pipes at the origin. The axes of the ellipse should the normal of the two vectors and their angle bisector.

Thanks for the patience ;)

Claudio

#### Attached Files:

• ###### Pipes.jpg
File size:
3.5 KB
Views:
92
Last edited: Apr 13, 2007
10. Apr 16, 2007

### Klaws

I managed to work around the ellipse issue in the xy-plane. I am now trying to use this matrix to rotate the axes. The problem is that I only have the unit vector for x' and not for y' and z'. Is there a way to define a rotation using only this vector and x,y,z? This should be possible because visually it's just like grabbing the x axis and and positioning it at x'. The other 2 axes should 'follow'.

Thank you,

Claudio

11. Apr 16, 2007

### D H

Staff Emeritus
Things don't work that way in 3D. There are many (uncountably many) rotations that take x to x', but only two will have the correct x'y' plane. (The y' unit vectors of the two solutions differ by sign.)

Fortunately, you do have a way to define all three axes. The two pipes define a plane. I assume you have vectors that define the orientation of these two pipes. The cross product of these two vectors is normal to each pipe. This forms the basis for one of your unit vectors (z'). You already have x'. y' is just the cross product of z' with x'.

12. Apr 16, 2007

### Klaws

Thanks DH,

I had arrived at that solution after working my way through vectors with the help of 3 pens (my DIY axes). I was just implementing it the wrong way.

My assumption that the axes should 'follow' was obviously wrong. I was still thinking 2D.

I'm starting to like this 3D stuff :)

I'm attaching my first 3D magnetic field. :) It's just built up using ellipses with no physical equations whatsoever. Suggestions as to how it could be more realistic are welcome. The tool is aimed at high school students learning A Level physics.

Claudio

File size:
75 KB
Views:
125