POV-Ray : Newsgroups : povray.advanced-users : Math question : Re: Math question Server Time
2 Nov 2024 05:18:18 EDT (-0400)
  Re: Math question  
From: Chris Huff
Date: 10 May 2000 09:02:51
Message: <chrishuff_99-0FD131.08061210052000@news.povray.org>
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

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