POV-Ray : Newsgroups : povray.general : Math Question : Re: Math Question Server Time
10 Aug 2024 15:23:59 EDT (-0400)
  Re: Math Question  
From: Josh English
Date: 2 Dec 1999 11:00:42
Message: <384697A8.B8EA05BB@spiritone.com>
There is a simple matrix tranformation you can use to orient everytthing. It
goes like this:

#declare Cam_Loc = wherever the camera is
#declare Obj_Loc = whereve the object

#macro Orient_Z(v1,v2)
  #local nz = vnormalize(v2 - v1);
  #local nx = vnormalize(vcross(nz,y));
  #local ny = vcross(nz,nx);
  matrix <nx.x,nx.y,nx.z,
          ny.x,ny.y,ny.z,
          nz.x,nz.y,nz.z,
          v1.x,v1.y,v1.z>
#end

box { <0,0,0> <1,1,0.01>
          pigment { image map details go here *** }
          transalate <-0.5,-0.5,0>
          scale appropriately
          Orient_Z(Obj_Loc, Cam_Loc)
         }

This version of the orient macro assumes something is designed along the Z
axis.

As far as the trig goes, it can be messy. Assume the camera stays at <0,0,0>
and the painting is at <10,0,0>, and limit it's movement only by translating it
along z, such as your example, then you have to remember that rotating an
object not located at the origin will move it as well as rotating it. Here I
will assume the painting setup as above, without the Orient_Z macro.

you have point p at <x,0,z> which is the final position of the painting.
 rotate arctan(p.z,p.x)*y
 translate p

Okay, simple, but if you want to move the painting in 3d space, use the Orient
macro, it's safer


Robert J Becraft wrote:

> I'm posting this because I'm sure it is a simple trig thing and that was too
> many years ago for me to remember it.
>
> I have an object... let us assume it is a picture for simplicity....
>
> camera ----->      picture
>
> In this scenario, the picture is perpendicular to the viewing angle of the
> camera.  What I want is the formula that will tell me how much to rotate the
> picture to keep the picture perpendicular when I MOVE the camera.
>
> For example, if the camera is at <0,0,0> and the picture is at <10,0,0>  and
> then I move the camera to <0,0,5>, how much do I need to rotate the picture
> to get it back to a 90 degree angle respective to the camera?   X,Z
> coordinates are fine, I don't need any 3-D solutions to this problem.
>
> Regards,
> Robert J Becraft
> aka cas### [at] aolcom

--

Josh English
eng### [at] spiritonecom
ICQ: 1946299
"Stress is when you wake up screaming and realize you haven't fallen asleep
yet."


Post a reply to this message

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