POV-Ray : Newsgroups : povray.newusers : Help with: (planar) Angle between 2 vectors : Help with: (planar) Angle between 2 vectors Server Time
4 May 2024 21:01:05 EDT (-0400)
  Help with: (planar) Angle between 2 vectors  
From: Bald Eagle
Date: 30 Jul 2014 15:45:00
Message: <web.53d94a479e261ad65e7df57c0@news.povray.org>
I'm just trying to return the angle between a fixed vector (pointing in the
-y*70 degrees direction) and the line of sight of the camera.
CL = Camera Location, LA = Look At point

I have a sort of crosshair that's centered at <45*8*Feet, 32*Feet, 55*8*Feet>,
which is why I have the translation in the vtransform.
I "project" the vectors onto the ground plane by just negating the y components
- multiplying that part of the dot product equation by zero.
(sorry for any of my non-mathematically correct terminology)
I get an answer of 9.2 degrees, but I was expecting zero, so I'm thinking I have
something off.

#declare CL = <45*8*Feet, 32*Feet, 55*8*Feet>;
#declare LA = vtransform (<0, 0, 10*8*Feet>, transform{rotate -y*70 translate
<45*8*Feet, 32*Feet, 55*8*Feet>});

// (CL.y * LA.y) defined to be planar - (0, 0)
#declare UdotV = (CL.x * LA.x) + (CL.y * LA.y) * 0 + (CL.z * LA.z);
#declare MagU = sqrt (pow (CL.x, 2) + pow (CL.y, 2) + pow (CL.z, 2) );
#declare MagV = sqrt (pow (LA.x, 2) + pow (LA.y, 2) + pow (LA.z, 2) );
#declare Angle = degrees (acos (UdotV / (MagU * MagV) ) );


Post a reply to this message

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