POV-Ray : Newsgroups : povray.advanced-users : Infernal rotations with Reorient: : Re: Infernal rotations with Reorient: Server Time
29 Jul 2024 04:20:39 EDT (-0400)
  Re: Infernal rotations with Reorient:  
From: Tor Olav Kristensen
Date: 25 Dec 2002 19:30:03
Message: <web.3e0a4cea6f9c8fac7d655a8f0@news.povray.org>
Greg M. Johnson wrote:
>My favorite macro is Reorient, but I'm always annoyed at how it will rotate
>an object along its axis as it reorients it.


Greg, if you want to force the rotation of the camera to
happen in the xy-plane only (i.e. around the y-axis), you
could do it like this:

// Untested code below
#version 3.5;
#include "transforms.inc"
....
#declare pNextCameraLocation = ...
#declare pNextCameraLookAtLocation = ...
....
#declare vCurrentLookDirection = z;
#declare vNextLookDirection = pNextCameraLookAtLocation -
pNextCameraLocation;

#declare vRotateFrom = vCurrentLookDirection*(x + z);
#declare vRotateTo = vNextLookDirection*(x + z);

#declare CameraTransform =
  transform {
    Reorient_Trans(vRotateFrom, vRotateTo)
    translate pNextCameraLocation
  }


Some further comments:

To find the axis that the reorientation will be done around,
you can take the cross product of the vector that points in
the object's current direction and the vector that points in
the direction that you want the object to point in.

This means that the Axis_Rotate_Trans() macro can be used
to reoerient objects in the same way as the Reorient_Trans()
macro can.

In some cases it may be useful to have the reorientation of
an object to happen in several small steps (e.g. along with
the clock for animations). This can be achieved with the
Axis_Rotate_Trans() macro.

(I can show some example code if anyone is interested.)


>What is more annoying is a fix:
>given a camlook_at variable and the camloke variable,  I was reorienting a
>camera and found the annoying rotation:
>
>//#declare cameratransform=transform{ Reorient (z,camlook_at-camloke)
>translate camloke}
>
>However, this gives the response I'm looking for, even if it is
>mathematically  close.
>
>#declare cameratransform=transform{ Reorient (z,seedirn*<1,0,1>) Reorient
>(seedirn*<1,0,1>,seedirn)translate camloke}

Btw.:
I just noticed that John has provided an alternative solution
to this problem in your "Derailed IRTC entry" thread:

http://news.povray.org/povray.off-topic/29424/


Tor Olav


Post a reply to this message

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