POV-Ray : Newsgroups : povray.general : Matrices : Re: Matrices Server Time
11 Aug 2024 11:21:05 EDT (-0400)
  Re: Matrices  
From: John VanSickle
Date: 7 Sep 1999 18:39:37
Message: <37D5977E.83926BF@erols.com>
Josh English wrote:
> 
> John VanSickle wrote:
> 
> > Larry Fontaine wrote:
> > >
> > > I made a TI-86 program to find POV-matrices. Just select the
> > > transform and enter the numbers. Maybe I'll post it.
> >
> > Bah.  I do them in my head.
>
> You do them in your head? I'm impressed... especially when it comes to
> figuring out sine and cosine values.
> 
> Can you teach me to do that? I'm going to teach math eventually, so I
> should probably learn to save face, or impress students.

I generally use them when I want to do two transforms at once.  The
first thing I do is to type out the identity matrix (the one that
doesn't make any changes):

  matrix <1,0,0, 0,1,0, 0,0,1, 0,0,0>

Then I go back and replace the elements with what's needed to accomplish
the transformation.  To save on typing, any value that is not a neat 
fraction or decimal value is assigned to a variable earlier on:

#local sC=sqrt(.75); // scalar containing a cosine value
#local sS=.5;        // scalar containing a sine value

For rotations, the cosine value replaces the 1 in the affected vectors.
For rotation around the x vector, we get:

  matrix <1,0,0, 0,sC,0, 0,0,sC, 0,0,0>

The sine values need to be plugged in; I visualize what a y-vector will
do when rotated as I desire (ie, whether it moves in the +z or -z
direction), and put the appropriate value into the matrix:

  matrix <1,0,0, 0,sC,sS, 0,-sS,sC, 0,0,0>
    // rotate x*degrees(atan2(sC,sS))

I can throw in my scaling as I go,

  matrix <sV,0,0, 0,sC,sS, 0,-sS,sC, 0,0,0> // scale <sV,1,1>

And then the translation,

  matrix <sV,0,0, 0,sC,sS, 0,-sS,sC, tX,tY,tZ>  // translate <tX,tY,tZ>

I generally don't try to multiply two matrices in my head or on paper,
unless I am reasonably sure that the product matrix will be as simple as
the multiplicands.  It's just as easy to invoke the two matrices in
succession.

That's enough brain calories for one day...
-- 
ICQ: 46085459


Post a reply to this message

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