rotating a point about another point

Posted on 2009-12-25
Last Modified: 2013-12-26
I've two points 'a' and 'b',
i do the following commands:

            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];


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?

Question by:khdani
    1 Comment
    LVL 4

    Accepted Solution


    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:

    Point a = 1,2,3;

    Vector b = 3,2,1;

    //now to rotate a around b

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


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

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    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 (, 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.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now