|
|
In article <3918D8BA.79E41F33@hotmail.com>, Pabs <pab### [at] hotmailcom>
wrote:
> Say I have a ray represented by a ray origin & a unit length direction
> vector and
> a point some-where along the ray - how do I find the distance along the
> ray in the direction of the ray's direction vector from the origin - ie
> in the below diagram the distance found would be negative
I think you are looking for the distance between two points. In POV
scenes, just use vlength(PtA-PtB). If in a POV patch, I think there is a
VDist() macro.
If in something else, it can be implemented like this:
double vdist(double x, double y, double z, double a, double b, double c)
{ return sqrt(sqr(x-a) + sqr(y-b) + sqr(z-c));}
Of course, you should probably use some kind of vector data type to
simplify things.
This gives you the distance, the direction(+/-) should be pretty easy to
figure out.
--
Christopher James Huff - Personal e-mail: chr### [at] yahoocom
TAG(Technical Assistance Group) e-mail: chr### [at] tagpovrayorg
Personal Web page: http://chrishuff.dhs.org/
TAG Web page: http://tag.povray.org/
Post a reply to this message
|
|