View Single Post
Old 22nd March 2005, 19:55   #229
q-vis
Junior Member
 
Join Date: Mar 2005
Location: germany
Posts: 3
Hi everyone!

Wrote a 3d rotation engine powered by Linear Algebra:

Init:
rx=...; ry=...; rz=...;

Per Frame:
srx=sin(rx); sry=sin(ry); srz=sin(rz);
crx=cos(rx); cry=cos(ry); crz=cos(rz);
r11=cry*crz; r12=-cry*srz; r13=sry;
r21=srx*sry*crz+crx*srz; r22=-srx*sry*srz+crx*crz; r23=-srx*cry;
r31=-crx*sry*crz+srx*srz; r32=crx*sry*srz+srx*crz; r33=crx*cry;

Per Point:
x1=...; y1=...; z1=...; //3D object
x2=r11*x1+r12*y1+r13*z1;
y2=r21*x1+r22*y1+r23*z1;
z2=r31*x1+r32*y1+r33*z1;

The point is to compute the entries of a full rotation matrix in the per frame section (instead of per point rotation). Hope this works faster, haven't tried it yet.
q-vis is offline   Reply With Quote