POV-Ray : Newsgroups : povray.advanced-users : Pov giving error when I use a matrix. I can't figure out why. : Pov giving error when I use a matrix. I can't figure out why. Server Time
29 Jul 2024 18:29:49 EDT (-0400)
  Pov giving error when I use a matrix. I can't figure out why.  
From: Dan Johnson
Date: 6 Jun 2001 04:19:59
Message: <3B1F398B.891ACAE1@hotmail.com>
I've been reading a book on quaternion rotators, and I wanted to test my
knowledge before I tried to do anything really complicated.  To use
quaternions in POV-Ray I needed to convert it into a matrix.  I haven't
used matrices in POV-Ray before, and that's where I get the error.  The
error states that after the the third term of the matrix it expects a >
instead of a comma.  Please can anyone tell me why I am getting that
error message.


// Begin code
#include "colors.inc"
#include "polyhedra.inc"

camera {location <0,0,-8> look_at 0 }
light_source {<2,30,-100> rgb 2}

#macro Quaternion(Angle,Vector)   // creates a normalized rotation
quaternion
        #if (vlength(Vector)=0) #warning "0 vector not allowed" #end
        #local A = Angle/2;
        #local V = sin(A)*vnormalize(Vector);
        <cos(A),V.x,V.y,V.z>
#end

#macro Q_conjugate(Q)    // the conjugate of a quaternion
        <Q.x,-Q.y,-Q.z,-Q.t>
#end

#macro Q_matrix (Q)      // converts a quaternion into a matrix
        #local Q0 = Q.x;
        #local Q1 = Q.y;
        #local Q2 = Q.z;
        #local Q3 = Q.t;
        #local QT = 2*pow(Q0,2)-1;
        matrix
        <QT+2*pow(Q1,2),2(Q1*Q2+Q0*Q3),2(Q1*Q3-Q0*Q2),
         2(Q1*Q2-Q0*Q3),QT+2*pow(Q2,2),2(Q2*Q3+Q0*Q1),
         2(Q1*Q3+Q0*Q2),2(Q2*Q3-Q0*Q1),QT+2*pow(Q3,2),
         0,0,0>
#end
#macro R(Axis,Angle) // rotates around axis by angle
        Q_matrix (Quaternion(Angle,Axis))
#end
#macro From_here_2_there (V1,V2) // rotates object pointing at V1 so
that it points at V2
        #local Angle = acos(vdot(V1,V2)/(vlength(V1)*vlength(V2)));
        #local Axis  = vcross (V1,V2);
        R(Axis,Angle)
#end

object {Dodecahedron_faces pigment {Red} From_here_2_there
(Icosahedron6,-z)}
// End Code

You can find polyhedra.inc here --->
http://www.geocities.com/zapob/pov/polyhedra_inc.zip
--
Dan Johnson

http://www.geocities.com/zapob


Post a reply to this message

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