Skip to main content
gamedev.net
🔒 Locked

Line Intersecting Sphere

Started by noaktree Apr 14, 2004 at 1:45 AM 2 replies 1.7k views
Original Post
noaktree
noaktree
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]
game development is liek a state of mind man.. it's liek when you liek... think... and then you liek make it fun++

- Yes I'm drunk.
jollyjeffers
jollyjeffers
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
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
jimmynelson
jimmynelson
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.
3dModelMan
3dModelMan
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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.