POV-Ray : Newsgroups : povray.beta-test : Axis_Rotate_Trans : Axis_Rotate_Trans Server Time
2 Nov 2024 03:14:23 EDT (-0400)
  Axis_Rotate_Trans  
From: mm
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

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