POV-Ray : Newsgroups : povray.advanced-users : Pov giving error when I use a matrix. I can't figure out why. Server Time
26 Nov 2024 01:47:15 EST (-0500)
  Pov giving error when I use a matrix. I can't figure out why. (Message 1 to 10 of 10)  
From: Dan Johnson
Subject: Pov giving error when I use a matrix. I can't figure out why.
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

From: Michael Andrews
Subject: Re: Pov giving error when I use a matrix. I can't figure out why.
Date: 6 Jun 2001 06:26:16
Message: <3B1E0660.AE850961@reading.ac.uk>
Dan,

>         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>

I think this should be

>         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>

right?

Bye,
	Mike Andrews.


Post a reply to this message

From: Dan Johnson
Subject: Re: Pov giving error when I use a matrix. I can't figure out why.
Date: 6 Jun 2001 06:57:39
Message: <3B1F5E81.187B259F@hotmail.com>
Michael Andrews wrote:
> 
> Dan,
> 
> >         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>
> 
> I think this should be
> 
> >         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>
> 
> right?
> 
> Bye,
>         Mike Andrews.

I didn't think that would make a difference, it does.  Problem solved,
thanks.
-- 
Dan Johnson 

http://www.geocities.com/zapob


Post a reply to this message

From: Ron Parker
Subject: Re: Pov giving error when I use a matrix. I can't figure out why.
Date: 6 Jun 2001 09:10:38
Message: <slrn9hsauf.4q8.ron.parker@fwi.com>
On Thu, 07 Jun 2001 03:59:13 -0700, Dan Johnson wrote:
>> >          2(Q1*Q2-Q0*Q3),QT+2*pow(Q2,2),2(Q2*Q3+Q0*Q1),

vs.

>> >          2*(Q1*Q2-Q0*Q3),QT+2*pow(Q2,2),2*(Q2*Q3+Q0*Q1),
>
>I didn't think that would make a difference, it does.  Problem solved,
>thanks.

The reason is that commas are optional in POV.  When it sees 2(blah) it parses
that as two separate terms, in the same way that it parses the (z+a z) on the
first line of my .signature as two terms.

-- 
#macro R(L P)sphere{L F}cylinder{L P F}#end#macro P(V)merge{R(z+a z)R(-z a-z)R(a
-z-z-z a+z)torus{1F clipped_by{plane{a 0}}}translate V}#end#macro Z(a F T)merge{
P(z+a)P(z-a)R(-z-z-x a)pigment{rgbf 1}hollow interior{media{emission 3-T}}}#end 
Z(-x-x.2x)camera{location z*-10rotate x*90normal{bumps.02scale.05}}


Post a reply to this message

From: Jaime Vives Piqueres
Subject: Re: Pov giving error when I use a matrix. I can't figure out why.
Date: 6 Jun 2001 13:51:56
Message: <3B1E6E65.7293F1B9@ignorancia.org>
Ron Parker wrote:
> that as two separate terms, in the same way that it parses the (z+a z) on > > the
first line of my .signature as two terms.
> 
> --
> #macro R(L P)sphere{L F}cylinder{L P F}#end#macro P(V)merge{R(z+a z)R(-z a-z)R(a
> -z-z-z a+z)torus{1F clipped_by{plane{a 0}}}translate V}#end#macro Z(a F T)merge{
> P(z+a)P(z-a)R(-z-z-x a)pigment{rgbf 1}hollow interior{media{emission 3-T}}}#end
> Z(-x-x.2x)camera{location z*-10rotate x*90normal{bumps.02scale.05}}

  A pain that mail clients don't render pov code... or perhaps OE can do
it and I've never noticed? ;)


-- 
Jaime Vives Piqueres

La Persistencia de la Ignorancia
http://www.ignorancia.org/


Post a reply to this message

From: Ken
Subject: Re: Pov giving error when I use a matrix. I can't figure out why.
Date: 6 Jun 2001 21:54:28
Message: <3B1EDE51.E15B60F9@pacbell.net>
Jaime Vives Piqueres wrote:
> 
> Ron Parker wrote:
> > that as two separate terms, in the same way that it parses the (z+a z) on > > the
first line of my .signature as two terms.
> >
> > --
> > #macro R(L P)sphere{L F}cylinder{L P F}#end#macro P(V)merge{R(z+a z)R(-z a-z)R(a
> > -z-z-z a+z)torus{1F clipped_by{plane{a 0}}}translate V}#end#macro Z(a F T)merge{
> > P(z+a)P(z-a)R(-z-z-x a)pigment{rgbf 1}hollow interior{media{emission 3-T}}}#end
> > Z(-x-x.2x)camera{location z*-10rotate x*90normal{bumps.02scale.05}}
> 
>   A pain that mail clients don't render pov code... or perhaps OE can do
> it and I've never noticed? ;)

Advanced users can parse and render it in their heads.

-- 
Ken Tyler


Post a reply to this message

From: Dan Johnson
Subject: Re: Pov giving error when I use a matrix. I can't figure out why.
Date: 6 Jun 2001 23:46:24
Message: <3B204AEE.24D99345@hotmail.com>
Ken wrote:
> 
> Jaime Vives Piqueres wrote:
> >
> > Ron Parker wrote:
> > > that as two separate terms, in the same way that it parses the (z+a z) on > >
the first line of my .signature as two terms.
> > >
> > > --
> > > #macro R(L P)sphere{L F}cylinder{L P F}#end#macro P(V)merge{R(z+a z)R(-z a-z)R(a
> > > -z-z-z a+z)torus{1F clipped_by{plane{a 0}}}translate V}#end#macro Z(a F T)merge{
> > > P(z+a)P(z-a)R(-z-z-x a)pigment{rgbf 1}hollow interior{media{emission 3-T}}}#end
> > > Z(-x-x.2x)camera{location z*-10rotate x*90normal{bumps.02scale.05}}
> >
> >   A pain that mail clients don't render pov code... or perhaps OE can do
> > it and I've never noticed? ;)
> 
> Advanced users can parse and render it in their heads.
> 
> --
> Ken Tyler

The computer is only for showing other people what's in our heads.  
-- 
Dan Johnson 

http://www.geocities.com/zapob


Post a reply to this message

From: David Fontaine
Subject: Re: Pov giving error when I use a matrix. I can't figure out why.
Date: 8 Jun 2001 18:23:12
Message: <3B214EBE.9ECACE7F@faricy.net>
Dan Johnson wrote:
> 
> I didn't think that would make a difference, it does.  Problem solved,
> thanks.

Yeah, the TI calcs can't do that either.  "Invalid implied multiply"
because that's function/program syntax, foo(parms).  Actually it's
fairly limited.  No half-angle formulae built in, so it gives you nice
ugly unsimplified trig.  Not very good at simplyfying radical
expressions either.

-- 
David Fontaine  <dav### [at] faricynet>  ICQ 55354965
My raytracing gallery:  http://davidf.faricy.net/


Post a reply to this message

From: Mark Wagner
Subject: Re: Pov giving error when I use a matrix. I can't figure out why.
Date: 9 Jun 2001 01:07:22
Message: <3b21af0a@news.povray.org>
David Fontaine wrote in message <3B214EBE.9ECACE7F@faricy.net>...
>Yeah, the TI calcs can't do that either.  "Invalid implied multiply"
>because that's function/program syntax, foo(parms

My TI-86 has no trouble figuring out that 2(5) = 10.

--
Mark


Post a reply to this message

From: David Fontaine
Subject: Re: Pov giving error when I use a matrix. I can't figure out why.
Date: 10 Jun 2001 01:16:55
Message: <3B230132.F2012904@faricy.net>
Mark Wagner wrote:
> 
> David Fontaine wrote in message <3B214EBE.9ECACE7F@faricy.net>...
> >Yeah, the TI calcs can't do that either.  "Invalid implied multiply"
> >because that's function/program syntax, foo(parms
> 
> My TI-86 has no trouble figuring out that 2(5) = 10.

Oh, stupid me!  But it can't do x(3) = 3x.  Obviously.  Still wish it
had half-angles though.

-- 
David Fontaine  <dav### [at] faricynet>  ICQ 55354965
My raytracing gallery:  http://davidf.faricy.net/


Post a reply to this message

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