Jump to content
  • Advertisement
Sign in to follow this  
pondwater

Ray cast from INSIDE sphere or cylinder

This topic is 2475 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

I've been using Christer Ericson's book for my standard ray-cast tests. Now in my particular case I need to cast a ray from a point that i know is contained by either a sphere or cylinder. I want to cast the ray outwards and get the appropriate t value and contact point on the boundary of the cylinder/sphere.

I figure that in the case of sphere or infinite cylinger i can simply solve for both t values and use those to figure out whats going on.

if discr < 0, theres no intersection,
if discr == 0, there is a simple contact tanger to surface, and
if discr > 0 there are 2 intersections. and 3 cases:

t1 and t2 are positive: the intersection is infront of the ray, i take the lowest t value for time of impact
t1 and t2 are negative: the intersection is behind the ray, return false
t1 is negative and t2 is positive: the ray origin is inside the object, the postive is its exit point in front of the ray. This is what i want?

Is this reasoning correct?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!