POV-Ray : Newsgroups : povray.beta-test : Axis_Rotate_Trans Server Time
30 Jul 2024 00:28:12 EDT (-0400)
  Axis_Rotate_Trans (Message 1 to 3 of 3)  
From: mm
Subject: Axis_Rotate_Trans
Date: 18 Jan 2002 01:39:17
Message: <3c47c315@news.povray.org>
POV 3.5 b 10, win

transforms.inc

macro Axis_Rotate_Trans bugs on Axis = <-1, 1, -1> : singular matrix
The reason why is clear from the text : local vY and vZ are then null.

I found no better way around that to test for the singular case. I set the
test to a rather big value (0.2) because for Axis different from but very
close to <-1, 1, -1> the matrix is not singular but not well conformed.

#macro Axis_Rotate_Trans(Axis, Angle)
    #local vX = vnormalize(Axis);
    #local vY = vnormalize(vcross(vX, <vX.y, vX.z,-vX.x>));
    #if (vY.x*vY.x+ vY.y*vY.y+vY.z*vY.z <0.2)
      #local vY = vnormalize(vcross(vX, <vX.y, vX.z, vX.x>));
    #end
    #local vZ = vnormalize(vcross(vX, vY));
    transform {
        matrix < vX.x,vY.x,vZ.x, vX.y,vY.y,vZ.y, vX.z,vY.z,vZ.z, 0,0,0 >
        rotate x*Angle
        matrix < vX.x,vX.y,vX.z, vY.x,vY.y,vY.z, vZ.x,vZ.y,vZ.z, 0,0,0 >
    }
#end


Post a reply to this message

From: Rune
Subject: Re: Axis_Rotate_Trans
Date: 18 Jan 2002 06:47:25
Message: <3c480b4d@news.povray.org>
"mm" wrote:
> macro Axis_Rotate_Trans bugs on Axis = <-1, 1, -1> : singular matrix
> The reason why is clear from the text : local vY and vZ are then null.

> I found no better way around that to test for the singular case.

Thanks for your efforts, but I'm going to use a different approach. The
current Axis_Rotate_Trans is written in a somewhat clumsy way, which also,
as you have shown, can cause errors. Unless anyone objects, I'm going to
replace it with the much cleaner approach below. I have no idea why the
original macro was written the way it was, instead of this simple way, but
if anyone know of any catches to the new approach, please let me know.

//rotate around a specific axis
#macro Axis_Rotate_Trans(Axis, Angle)
    #local vX = vaxis_rotate(x,Axis,Angle);
    #local vY = vaxis_rotate(y,Axis,Angle);
    #local vZ = vaxis_rotate(z,Axis,Angle);
    transform {
        matrix < vX.x,vX.y,vX.z, vY.x,vY.y,vY.z, vZ.x,vZ.y,vZ.z, 0,0,0 >
    }
#end

Rune
--
3D images and anims, include files, tutorials and more:
Rune's World:    http://rsj.mobilixnet.dk (updated Jan 2)
POV-Ray Users:   http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Webring: http://webring.povray.co.uk


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Axis_Rotate_Trans
Date: 21 Jan 2002 19:47:31
Message: <3C4CB61B.715AF0C4@hotmail.com>
Rune wrote:
> 
> "mm" wrote:
> > macro Axis_Rotate_Trans bugs on Axis = <-1, 1, -1> : singular matrix
> > The reason why is clear from the text : local vY and vZ are then null.
> 
> > I found no better way around that to test for the singular case.
> 
> Thanks for your efforts, but I'm going to use a different approach. The
> current Axis_Rotate_Trans is written in a somewhat clumsy way, which also,
> as you have shown, can cause errors. Unless anyone objects, I'm going to
> replace it with the much cleaner approach below. I have no idea why the
> original macro was written the way it was, instead of this simple way,
>...

The AxisRotate() macro has been part of John VanSickle's
"Thoroughly Useful Macros" collection since at least 28.
August 1999. (I.e. LONG before most of us figured out how
to write pov-macros that does it otherwise.)

http://news.povray.org/povray.general/1786/


Tor Olav


Post a reply to this message

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