• Advertisement

Archived

This topic is now archived and is closed to further replies.

Line Intersecting Sphere

This topic is 5060 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Sphere Pic
Hi I'm stuck and I need some help. Using C++ and DirectX 9 I simply want to find the most efficient way to calculate a point on a sphere where a line extending from the center intersects the sphere. The line is rotated at angle (rx,ry,rz). Another way to look at this problem is to say I have a line of x length that has one end at a known (x,y,z) and is rotated (rx,ry,rz). I need an easy way to calculate the other end point on the line. Not so good at math so please help. Does directx offer any functions or objects that would make this easy? [edited by - noaktree on April 14, 2004 2:46:56 AM]

Share this post


Link to post
Share on other sites
Advertisement
You''ll get a better response from the "Maths and Physics" forum - maybe one of the moderators could move the thread for you...

Anyway, off the top of my head, you''d probably want to look into using polar coordinates, they''re usually pretty good at this sort of thing

Look up the help file contents for D3DX math functions, see if any of those look like the thing you want.

hth
Jack

Share this post


Link to post
Share on other sites
Tell me what you are trying to do and maybe I can help. I can''t think of a reason why you would wanna do what you are doing. Cause in most 3d mathematics you use simple repetitive concepts to get what you want. There is a method to tell the closest point on a line to another point.

So once you had that point you can take the distance between 2 points and see if the line intersects the sphere. But if you wanted to get the hit point on the sphere you would would have to add a little more math.

Trigonometry will help you there. You now can create a line from the center of the sphere to the point to the sphere. Then you just need to fine the next point which length is the radius and lies on that original line.

Share this post


Link to post
Share on other sites
If you forgive the fact that I''ve just published this from MS-Word, you''ll see it''s one of my revision notes on ray/sphere intersection, with code, a fully dimensioned diagram, and a walk-through sample. If you have the slightest knowledge of vector math it should be all you need.

You won''t need the "More elaborate" method at the bottom of the page...

Click here

Share this post


Link to post
Share on other sites

  • Advertisement