What is the Equation of the Ellipse in 3D for Magnetic Field Visualization?

  • Context: Graduate 
  • Thread starter Thread starter Klaws
  • Start date Start date
  • Tags Tags
    3d Ellipse
Click For Summary
SUMMARY

The discussion focuses on deriving the equation of an ellipse in 3D for visualizing magnetic fields using DirectX. The user, Claudio, seeks to connect two pipes represented by direction vectors at the origin with an ellipse that bisects the angle between them. A rotation matrix is defined to transform the ellipse from the global coordinate system to the pipe coordinate system. The conversation emphasizes the importance of using the cross product of the two vectors to establish a complete coordinate system for accurate ellipse definition.

PREREQUISITES
  • Understanding of 3D vector mathematics
  • Familiarity with rotation matrices
  • Knowledge of DirectX for 3D graphics programming
  • Basic principles of magnetic field visualization
NEXT STEPS
  • Study the construction and application of rotation matrices in 3D space
  • Learn about the cross product and its role in defining orthogonal vectors
  • Explore DirectX techniques for rendering 3D curves and shapes
  • Research mathematical representations of ellipses in 3D coordinates
USEFUL FOR

This discussion is beneficial for 3D graphics developers, physics educators, and students interested in visualizing magnetic fields and understanding vector mathematics in three dimensions.

Klaws
Messages
7
Reaction score
0
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.
 
Physics news on Phys.org
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.
 
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
 
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?
 
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
 
Klaws said:
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

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 each other?
 
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.
 
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 each other. How do these two axes depend on the direction of the two vectors?
 
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
 

Attachments

  • Pipes.jpg
    Pipes.jpg
    3.5 KB · Views: 704
Last edited:
  • #10
christianjb said:
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.


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
Klaws said:
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'.

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
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.

Thanks for your precious help,

Claudio
 

Attachments

  • Magnet.jpg
    Magnet.jpg
    72.7 KB · Views: 827

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
Replies
1
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 42 ·
2
Replies
42
Views
7K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 44 ·
2
Replies
44
Views
25K