[PD] Advice: best way to do matrix-rotation in PD

Frank Barknecht fbar at footils.org
Sun Apr 3 19:01:03 CEST 2005


Hallo,
B. Bogart hat gesagt: // B. Bogart wrote:

> How do I specify the angle of rotation using matrix multiplication?

Attached is an example for a rotation of a 3-dimensional vector around
the x-axis, which is straight from a geometrY book like this:
http://mathworld.wolfram.com/RotationMatrix.html

It's basically the same thing that you are doing, however it's
simplified for educational purposes. ;) (The expr can be optimized a
bit of course.)

Rotation simply is matrix multiplication using matrices which follow
certain rules. For many purposes the three Rx, Ry and Rz matrices from
the mathworld site are sufficient, which are easy to use in zexy-mtx
objects. But you can also create more complex rotation matrices. For
this some more math might be needed: 
http://mathworld.wolfram.com/EulerAngles.html

NB: I heard, that there is a nameclash somewhere with the
[matrix] object so I always use the objects using their [mtx]
abbreviation to be on the safe side.

Ciao
-- 
 Frank Barknecht                               _ ______footils.org__
             
          _ __latest track: "scans" _ http://footils.org/cms/show/41
-------------- next part --------------
#N canvas 123 79 665 514 10;
#X obj 87 289 mtx 3 3;
#X obj 87 141 expr cos($f1) \; sin($f1) \; -sin($f1) \; cos($f1);
#X obj 87 217 pack 0 0 0 0;
#X msg 87 246 matrix 3 3 1 0 0 0 \$1 \$2 0 \$3 \$4;
#X floatatom 87 58 5 0 0 1 angle_in_degree - -;
#X obj 192 361 mtx_*;
#X obj 346 294 mtx 3 1;
#X floatatom 346 209 5 0 0 0 - - -;
#X floatatom 87 109 5 0 0 1 angle_in_radians - -;
#X obj 87 417 mtx_print;
#X obj 87 394 spigot;
#X obj 124 372 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
1;
#X obj 192 451 mtx_print;
#X obj 192 428 spigot;
#X obj 229 406 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1
1;
#X obj 346 426 mtx_print;
#X obj 346 403 spigot;
#X obj 383 381 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
1;
#X obj 87 80 / 57.2957;
#X text 363 106 0 cos(a) sin(a);
#X text 364 124 0 -sin(a) cos(a);
#X text 364 86 1 0 0;
#X text 336 83 |;
#X text 336 97 |;
#X text 336 113 |;
#X text 336 129 |;
#X text 497 81 |;
#X text 497 95 |;
#X text 497 111 |;
#X text 497 127 |;
#X text 301 56 Rotation around x-axis:;
#X msg 346 233 matrix 3 1 1 \$1 0;
#X connect 0 0 5 0;
#X connect 0 0 10 0;
#X connect 1 0 2 0;
#X connect 1 1 2 1;
#X connect 1 2 2 2;
#X connect 1 3 2 3;
#X connect 2 0 3 0;
#X connect 3 0 0 0;
#X connect 4 0 18 0;
#X connect 5 0 13 0;
#X connect 6 0 5 1;
#X connect 6 0 16 0;
#X connect 7 0 31 0;
#X connect 8 0 1 0;
#X connect 10 0 9 0;
#X connect 11 0 10 1;
#X connect 13 0 12 0;
#X connect 14 0 13 1;
#X connect 16 0 15 0;
#X connect 17 0 16 1;
#X connect 18 0 8 0;
#X connect 31 0 6 0;


More information about the Pd-list mailing list