[PD] Advice: best way to do matrix-rotation in PD
ben at ekran.org
Sat Apr 2 22:05:59 CEST 2005
How do I specify the angle of rotation using matrix multiplication?
Code I have used in the past has been:
for(i=0; i<8; i++)
tx = cos(zangle)*(points[i])+sin(zangle)*(points[i]);
x1 = cos(yangle)*(tx)+sin(yangle)*(points[i])+200;
y1 = (-sin(zangle))*(points[i])+cos(zangle)*(points[i])+200;
z1 = (-sin(yangle))*(tx)+cos(yangle)*(points[i]);
where "points" stores the positions of each point in a shape. I is the
point # (8 points for a cube in this case) and :X, :Y and :Z)
So the new position is set based on the previous position. What I can't
remeber is what tx is for... when I already have x1, y1 and z1....
Using zexy can I just store the current position of the points in an
matrix, do the rotation and replace the old positions with the rotated
ones? Then the matrix itself is what stores the points and I'll dump it
out as messages to set the control points.
I'll take a peek at the zexy matrix stuff...
Thanks for the tips.
Frank Barknecht wrote:
> B. Bogart hat gesagt: // B. Bogart wrote:
>>So I had the great idea of using matrix rotation to rotate the control
>>points on various axes to distort the cube. In order to get this to work
>>I need to solve two problems:
>>A. I need to be able to do matrix-rotation fast and efficiently, and I'd
>>rather not need an external to do it!
> I'm not sure that I understand what exactly you want to do, but to me
> it sounds as if this would be a simple task for zexy's matrix/mtx
> objects. Matrix rotation then simply is a multiplication of two
> matrices using [mtx_mult] rsp. [mtx_*] The only real problem then
> would be point B:
>>B. I need to query the current position of each point before I can
> namely building the matrices from the 3D data, but the needed data
> probably already is available somewhere.
> Of course zexy is an external library, but I suppose it's installed
> more often than [py].
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 256 bytes
Desc: OpenPGP digital signature
More information about the Pd-list