• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 671
  • Last Modified:

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_MODELVIEW_MATRIX, 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?



0
khdani
Asked:
khdani
1 Solution
 
gsx1022Commented:
Hi,

If I did not misunderstand you, you would like to rotate a point around a vector. This can easily be done by giving glRotatef the angle, and the vector you would like to rotate around, as parameters.

So something like this would work I guess:
[code]

Point a = 1,2,3;

Vector b = 3,2,1;

//now to rotate a around b

glRotatef(angle, b.x, b.y, b.z)

[/code]

Sorry for my bad english, and your time if I misunderstood you.
gsx1022
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now