Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7746555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:18:31+00:00 2026-06-01T10:18:31+00:00

Using Android opengl I need to move an object from point A to point

  • 0

Using Android opengl I need to move an object from point A to point B and rotate it around its local Z axis in the same time. I have been reading tutorials for the past 3 days, everybody gives you bits of informations and hints, but nobody is capable of explaining this from top to bottom for beginners.

I know how to only translate the object from point A to point B.
I also know how to rotate the object in point A around its local axis (translate it to origin, rotate it, translate it back)
I DON’T know how to rotate and translate in the same time.

I’ve tried to translate to origin, rotate, translate back, then translate to point B. It doesn’t work, and I think I know why (the rotation is messing the object axis, so the translation to point B is incorrect)

A(-x1, y1 , -z1)
B(-x1 + deltaX, y1 + deltaY, -z1 + deltaZ)
_gl.glTranslatef(x1, -y1 , z1);         
_gl.glRotatef(degrees, x1, -y1 , z1);                               
_gl.glTranslatef(-x1, y1 , -z1);
_gl.glTranslatef(deltaX, deltaY, deltaZ);

I need to take into consideration the way the rotation is chaning the axes. Some say I can do that with quaterninons, or with rotation matrixes, etc.
But I don’t have enough opengl knowledge to use apis to resolve this.

Can someone explain this to me? With somecode also?

Thank you in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T10:18:33+00:00Added an answer on June 1, 2026 at 10:18 am

    If you have the following code:

    glTranslate(x, y, z);
    glRotatef(angle, 0, 0, 1);
    drawObject();
    

    The object will first be rotated around it’s local z-axis and then translated with (x, y, z). The transform call that is closest to the draw call is the one that happens first.

    From your code it seems like you actually don’t want to rotate the object around it’s own origin but some other point, in this case you should do the following:

    glTranslate(x, y, z);                         //Transform 4
    glTranslate(origin.x, origin.y, origin.z);    //Transfrom 3
    glRotatef(angle, 0, 0, 1);                    // Transform 2 
    glTranslate(-origin.x, -origin.y, -origin.z); // Transform 1
    drawObject();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm porting an OpenGL app from the iPhone to Android, and I need to
While there are many samples around about using OpenGL ES on Android all of
I need to draw a spinning globe using opengl es in android. I think
I load obj models and try to render them with OpenGL ES using Android
Working through some OpenGL-ES tutorials, using the Android emulator. I've gotten up to texture
Ahoy, I'm working on an OpenGL ES based game for Android using the NDK.
I'm currently using OpenGL on Android to draw set width lines, which work great
I have a problem using opengl on android to draw a simple rectangle. This
I'm currently developing a game for Android using OpenGL ES 2.0. I have almost
I have gotten text to render using opengl es on android and currently am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.