POV-Ray : Newsgroups : povray.advanced-users : For the love of dot products! : Re: For the love of dot products! Server Time
28 Jul 2024 20:27:05 EDT (-0400)
  Re: For the love of dot products!  
From: Slime
Date: 14 Apr 2004 14:57:31
Message: <407d899b$1@news.povray.org>
> I'm not totally
> sure why you can substitute "V" for "P", and <X0,Y0,Z0>, but when I do I
> get the result for "C".

V, in the link you provided, is the beginning of the intersecting ray *with
respect to the sphere's location*. So, it's like, if you move the sphere to
the origin and the ray along with it, then the ray's new position will be V.
If the sphere is already centered at the origin, then V = P. It's just that
the intersection code has to be able to assume that the sphere is centered
on the origin, so it calculates V and it can then make that assumption.

> And last I always get a 2 in "P.D" for the "B"
> coefficient.


What they have done is considered D2 to be 1/2*B, and then used the
quadratic formula but replacing every occurance of B with 2*D2. The 2's end
up cancelling out with other 2's and 4's in the quadratic formula. So in
other words, they left out the 2 because it allows them to leave out more
coefficients later on (which would cancel out the 2), resulting in less
work.

With that in mind, it seems like you are well on your way to figuring out
this intersection algorithm.


By the way: I'd like to point out that this:
    #local T1 = (-DV+SQ)/D2;
    #local T2 = (-DV-SQ)/D2;
    #local Result = (T1<T2 ? T1 : T2);

can be safely replaced with this:
    #local Result = (-DV-SQ)/D2;

The reason being that we know that SQ is positive (we checked to make sure
it was earlier), So T2 will *always* be less than T1. Unless, of course, D2
is negative, but that can't be the case because D2 is the dot product of a
vector with itself (always >= zero).

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.