|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
ray --------------|------------------------------------->
^ ray
| origin
point on dist = 0
ray
dist = -1
Post a reply to this message
Attachments:
Download 'us-ascii' (1 KB)
|
|
| |
| |
|
|
|
|
| |
| |
|
|
#macro Dist(RayOrigin, Direction, Point)
((Point.x-RayOrigin.x)/Direction.x)
#end
// supposing that 'Direction' actually is a unit vector
--
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On 10 May 2000 06:44:41 -0400, Warp <war### [at] tagpovrayorg> 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
Peter Popov ICQ : 15002700
Personal e-mail : pet### [at] usanet
TAG e-mail : pet### [at] tagpovrayorg
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
In article <391A13E8.53BB7F05@hotmail.com>, Pabs <pab### [at] hotmailcom>
wrote:
> I tried using VDist & the result is always positive because -ve * -ve =
> +ve
The point direction should not be difficult to figure out...something
like this maybe(I am tired and this is untested, so be warned):
O = ray origin(vector)
Pt = point on ray(vector)
Dir = ray direction(normalized vector)
Dist = point distance, calculated with VDist(floating point)
DBL cosA = 0;
VECTOR tmp;
VSub(tmp,Pt,O);
VNormalizeEq(tmp);
VDot(cosA, Dir, tmp);
if(cosA<0)
{ Dist *= -1;}
This basically flips the number(positive to negative) if the point and
the direction are not on the same side of the ray. I think.
--
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> This basically flips the number(positive to negative) if the point and
> the direction are not on the same side of the ray. I think.
THANKS - IT WORKS
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |