• Advertisement

Archived

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

ray/sphere intersection

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

Im having a problem with ray/sphere intersection math. I have programmed the intersection code the geometric way as its faster and makes more sence. But now im trying to test it and I keep getting unreal roots when trying to solve the equation. heres a very asic setup i was going to start out with http://www.redbrick.dcu.ie/~mcbain/question.jpg so after the math of subtituting the ray equation for the sphere equation, and having your ray direction as a unit vector. I get the roots to be. a = 1 ; b = 2(Dotproduct (V,(p0 - s0)) c = Magnitude(p0 - s0) squared - radius squared. for B I get -4 and C = 7 so b^2 = 16 and 4*c = 28 b^2- 4ac = -12 which cannot be. the ray definatly intersect so im confused as to where im going wrong in the math !!!. heres my workings b = 2( 0.5(2-4) + 0.5(1-3)) = -4 c = ( (2-4)^2 + (1-3)^2)^1/2 - 1^2 = 7 It has to be somehting silly that im missing !!!!

Share this post


Link to post
Share on other sites
Advertisement
Its not the theory im having problems with its
my working out of the math.

Im fairly sure that the way im going about it
is right, but somewhere in my math (hopefully
someone will show me) im cocking up.

Share this post


Link to post
Share on other sites
quote:
Original post by SCRUB
...and having your ray direction as a unit vector...

b = 2( 0.5(2-4) + 0.5(1-3)) = -4
c = ( (2-4)^2 + (1-3)^2)^1/2 - 1^2 = 7



Here you haven''t normalized v. If you replace the 0.5s with "root 2 over 2" - I don''t know of a better way to put that - you should get the right answer (well, it works for me). I get b to be -4*(root 2). I hope that relieves some frustration,

Miles

Share this post


Link to post
Share on other sites
thats the ticket ,jasus , thanks very much I was going out of my nut there.

mucho grascious senoir Miles

Share this post


Link to post
Share on other sites

  • Advertisement