Solved

# rotating a point about another point

Posted on 2009-12-25
655 Views
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);

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
Question by:khdani
1 Comment

LVL 4

Accepted Solution

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

### Suggested Solutions

What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.