khdani
asked on
rotating a point about another point
Hello,
I've two points 'a' and 'b',
i do the following commands:
[code]
float m[] = new float[16];
gl.glTranslatef(a.x, a.y, a.z);
gl.glRotatef(90.0f, 0.0f, 0.0f, 1.0f);
gl.glTranslatef(-a.x, -a.y, -a.z);
gl.glGetFloatv(GL.GL_MODEL VIEW_MATRI X, m, 0);
gl.glLoadIdentity();
float[] point = new float[4];
float[] bp = b.getPoints();
point[0] = m[0] * bp[0] + m[4] * bp[1] + m[8] * bp[2] + m[12] * bp[3];
point[1] = m[1] * bp[0] + m[5] * bp[1] + m[9] * bp[2] + m[13] * bp[3];
point[2] = m[2] * bp[0] + m[6] * bp[1] + m[10] * bp[2] + m[14] * bp[3];
point[3] = m[3] * bp[0] + m[7] * bp[1] + m[11] * bp[2] + m[15] * bp[3];
[/code]
after that, i get a point which is perpendicular to point 'a',
now i want this new point rotate around the vector 'ab',
how can i do it?
I've two points 'a' and 'b',
i do the following commands:
[code]
float m[] = new float[16];
gl.glTranslatef(a.x, a.y, a.z);
gl.glRotatef(90.0f, 0.0f, 0.0f, 1.0f);
gl.glTranslatef(-a.x, -a.y, -a.z);
gl.glGetFloatv(GL.GL_MODEL
gl.glLoadIdentity();
float[] point = new float[4];
float[] bp = b.getPoints();
point[0] = m[0] * bp[0] + m[4] * bp[1] + m[8] * bp[2] + m[12] * bp[3];
point[1] = m[1] * bp[0] + m[5] * bp[1] + m[9] * bp[2] + m[13] * bp[3];
point[2] = m[2] * bp[0] + m[6] * bp[1] + m[10] * bp[2] + m[14] * bp[3];
point[3] = m[3] * bp[0] + m[7] * bp[1] + m[11] * bp[2] + m[15] * bp[3];
[/code]
after that, i get a point which is perpendicular to point 'a',
now i want this new point rotate around the vector 'ab',
how can i do it?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.