POV-Ray : Newsgroups : povray.general : an extraordinary rotation question : Re: an extraordinary rotation question Server Time
30 Jul 2024 08:19:49 EDT (-0400)
  Re: an extraordinary rotation question  
From: Tim Attwood
Date: 19 Jun 2009 22:29:21
Message: <4a3c4981$1@news.povray.org>
> Where do you come up with the <-0.5,-0.5,0> for multiplication. 

<-0.5,-0.5,0> is the coordinate of of the lower-left-forward corner
of the BOX mesh, which is the _box mesh <-49.999,-49.999,0.001>
scaled by 0.01 (and rounded a bit).

> Why do you sometimes add then multiply? 

Addition is equivalent to translation.
So if you have a point at coordinate A and 
translate it by amount B the point is now at
coordinate A+B.

Scaling is equavalent to multiplication.
So if you have a point at coordinate A and 
scale it by amount B, the point is now at 
coordinate A*B. 

You need to be careful with scaling, for
example if you have box{<1,1,1>,<2,2,2>}
and want to triple the size of the box, you
might just scale <3,3,3>, that triples the
size of the box fine, but now it's equivalent
to box{<3,3,3>,<6,6,6>}... it's now moved.
To keep the corner at <1,1,1> you need to
move it to the origin, scale, then put it back. 

>Where specifically can I learn more about matrix 
>manipulations in povray? 

Matrix transforms in POV are equivalent to
multiplying a vector by a 4x4 matrix. The
4th column is assumed to be 0 0 0 1.
Matrix math is covered in linear algebra in
college, I think. The bits to know for POV are...

(1) not all matrix tranforms result in a
valid transform, you could get errors if
you feed it nonsense numbers.

(2) given a matrix (POV docs 2.2.7.1.4) 
matrix <Val00, Val01, Val02,
        Val10, Val11, Val12,
        Val20, Val21, Val22,
        Val30, Val31, Val32>
the result if applied to a point P=<px,py,pz>
is a point Q=<qx,qy,qz> where
qx = Val00 * px + Val10 * py + Val20 * pz + Val30 
qy = Val01 * px + Val11 * py + Val21 * pz + Val31 
qz = Val02 * px + Val12 * py + Val22 * pz + Val32 

(3) a surface of an object is actually a set of points,
so a matrix transform applied to an object moves
all the points (it moves the object). It could scale, 
rotate, and translate, or some form of all three.
Most importantly, it can shear.

(4) Val30, Val31, Val32 (row 4) in a matrix transform
represents a translatation value.

(5) Val00, Val01, Val02  (row 1) in a matrix transform
represents the desired new X direction.

(6) Val10, Val11, Val12  (row 2) in a matrix transform
represents the desired new Y direction.

(7) Val20, Val21, Val22 (row 3) in a matrix transform
represents the desired new Z direction.

(8) The magnitude of the direction "vectors" (5-7) control
scaling.

(9) If you have a matrix transform T1 and a matrix transform
T2, then applying T1 and then T2 to an object is equivalent
to applying a transform T3=T1*T2, with some moderately 
complicated matrix multiplication rules. In other words,
behind the scenes, the list of transforms (translate, rotate, 
scale, matrix) that you feed to an object in POV are reduced 
to a single transform during the parse phase, no matter how
many transforms you use, they're a fixed (per object) cost.

>Sorry for being a burden, Thank you.

No problem.


Post a reply to this message

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