POV-Ray : Newsgroups : povray.newusers : Help with: (planar) Angle between 2 vectors : Re: Help with: (planar) Angle between 2 vectors Server Time
4 May 2024 16:48:26 EDT (-0400)
  Re: Help with: (planar) Angle between 2 vectors  
From: Bald Eagle
Date: 30 Jul 2014 23:00:01
Message: <web.53d9b01af138c3965e7df57c0@news.povray.org>
> 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));

Right, I figured that there must be some of those black-box operations
somewhere, but I have a thing about seeing the "guts" of the math taking place.
(BTW, it's vdot(U,V) in case someone tries to follow this thread.)

I now get 7.9 degrees.

Then I figured, maybe there's a few more vector tricks that POV-Ray can do:

#declare Angle = VAngleD(VProject_Plane (CL, y),VProject_Plane (LA, y));

Still yields 7.9

So, follow me here:
#declare CL = <45*8*Feet, 32*Feet, 55*8*Feet>;
this I guess is the "tail" of the vector.

Then I take a vector pointing "forward" in the positive z direction.
I rotate it -70 degrees around the y-axis / origin.
I then translate that vector so that ITS "tail" is at the same place (with
regard to x and z) as the camera vector.

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

And I think I just gave myself the nudge I needed.  Those vectors aren't where
and pointing where I thought they were.  Those are the heads of the vectors, and
the tails are at the origin, aren't they?

I'd need to .... create a true line-segment as my "vector" (LA-CL), and NOT
translate the -70 degree reference vector away from the origin, wouldn't I?

[Everyone wait while I switch windows...]

Wicked awesome.
LA is now a true look_at value:  <45*8*Feet, 32*Feet, 65*8*Feet>
pointing in the +z direction, and the same x value.


#declare CL2 = (LA-CL);
#declare LA2 = vtransform (<0, 0, 10*8*Feet>, transform{rotate -y*70 });
#declare Angle = VAngleD(VProject_Plane (CL2, y),VProject_Plane (LA2, y));

And THAT spits out an angle of +70 degrees, which is correct.

Summary:  the confusion was predominately with the definition of a "vector" -
which I think was a problem about a year ago.
Thankfully, I have disabused my mind of the misunderstanding.
This time.
For now.

:O


Post a reply to this message

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