|
|
Am 30.07.2014 21:40, schrieb Bald Eagle:
> 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) ) );
For ease of understanding and less possibilities to goof up, try using:
#declare U = vnormalize(CL*<1,0,1>);
#declare V = vnormalize(LA*<1,0,1>);
#declare Cos = dot(U,V);
#declare Angle = degrees(acos(Cos));
Post a reply to this message
|
|