POV-Ray : Newsgroups : povray.advanced-users : Math question : Re: Math question Server Time
2 Nov 2024 05:21:46 EDT (-0400)
  Re: Math question  
From: Pabs
Date: 10 May 2000 22:01:20
Message: <391A13E8.53BB7F05@hotmail.com>
Peter Popov wrote:

> > // supposing that 'Direction' actually is a unit vector
>
> Or if it's not:
>
> #macro Dist(RayOrigin, Direction, Point)
>   #local Dir=vnormalize(Direction);
>   ((Point.x-RayOrigin.x)/Dir.x)
> #end
>

Will try this - actually this is for part of a patch (ParticlePatch)
Chris Huff wrote:

> 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.

I tried using VDist & the result is always positive because -ve * -ve = +ve

Thanks all
Pabs


Post a reply to this message

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