Started by Aug 24 2001 05:43 AM

,
4 replies to this topic

Posted 24 August 2001 - 05:43 AM

how can i rotate a vector by a certain amount of degrees ?
is it possible or do i have to rotate the vector by a matrix ?

Posted 26 August 2001 - 06:39 AM

this was done for a java applet the formula is fine if i could only get the damn kinks out of the rest of the applet

here xa,ya,za is the point of the vertice loades in from a array 1 at a time hope it helps

Xa=Xp[vv][v];

Ya=Yp[vv][v];

Za=Zp[vv][v];

// improvised on the rotation formula because

// all the examples for simultaneous operations were for matrixes only

// this is a simultaneous operation on all 3 axis without a matrix

//System.out.println( "*********x*y*z*rotating on the axis''es" );

// rotate on the z axis

Xb = (int)(Xa * Math.cos(radiansZ) - Ya * Math.sin(radiansZ) );

Yb = (int)(Ya * Math.cos(radiansZ) + Xa * Math.sin(radiansZ) );

// rotate on the x axis

Yb = (int)(Yb * Math.cos(radiansX) - Za * Math.sin(radiansX) );

Zb = (int)(Yb * Math.sin(radiansX) + Za * Math.cos(radiansX) );

// rotate on the y axis

Zb = (int)(Zb * Math.cos(radiansY) - Xb * Math.sin(radiansY) );

Xb = (int)(Zb * Math.sin(radiansY) + Xb * Math.cos(radiansY) );

// place into temp array for drawing manipulation

// add a screen offset so its not spining around coordinates 0,0 x y

Xtemp[v] = Xb+off_set;

Ytemp[v] = Yb+off_set;

Ztemp[v] = Zb;

here xa,ya,za is the point of the vertice loades in from a array 1 at a time hope it helps

Xa=Xp[vv][v];

Ya=Yp[vv][v];

Za=Zp[vv][v];

// improvised on the rotation formula because

// all the examples for simultaneous operations were for matrixes only

// this is a simultaneous operation on all 3 axis without a matrix

//System.out.println( "*********x*y*z*rotating on the axis''es" );

// rotate on the z axis

Xb = (int)(Xa * Math.cos(radiansZ) - Ya * Math.sin(radiansZ) );

Yb = (int)(Ya * Math.cos(radiansZ) + Xa * Math.sin(radiansZ) );

// rotate on the x axis

Yb = (int)(Yb * Math.cos(radiansX) - Za * Math.sin(radiansX) );

Zb = (int)(Yb * Math.sin(radiansX) + Za * Math.cos(radiansX) );

// rotate on the y axis

Zb = (int)(Zb * Math.cos(radiansY) - Xb * Math.sin(radiansY) );

Xb = (int)(Zb * Math.sin(radiansY) + Xb * Math.cos(radiansY) );

// place into temp array for drawing manipulation

// add a screen offset so its not spining around coordinates 0,0 x y

Xtemp[v] = Xb+off_set;

Ytemp[v] = Yb+off_set;

Ztemp[v] = Zb;

Posted 26 August 2001 - 06:42 AM

btw

it use radians math.pi is just pie

double radiansZ = ( Math.PI * degreesZ )/180;

double radiansX = ( Math.PI * degreesX )/180;

double radiansY = ( Math.PI * degreesY )/180;

it use radians math.pi is just pie

double radiansZ = ( Math.PI * degreesZ )/180;

double radiansX = ( Math.PI * degreesX )/180;

double radiansY = ( Math.PI * degreesY )/180;

Posted 26 August 2001 - 06:52 AM

one more thing im gonna post the entire code in the java

programing forum if anyone can help me figure out why the heck

this applet cause the error it cause plz help no one in the sun forums has a answer

programing forum if anyone can help me figure out why the heck

this applet cause the error it cause plz help no one in the sun forums has a answer