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

  • SEARCH
  • Home
  • 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 8814069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:00:53+00:00 2026-06-14T04:00:53+00:00

I have a rotating object rotating about 0,0,0. I now want another object to

  • 0

I have a rotating object rotating about 0,0,0. I now want another object to rotate about the other object. so kind of like the earth rotating around the sun and then the moon rotating around the earth.
I am not sure how to go about this.

void earth(){
glPushMatrix();
    glRotatef(anglee, 1.0f, 0.0f, 0.0f);
    glTranslatef(0.0,20,0);
    glutSolidSphere(0.8,50,50);
glPopMatrix();

glPushMatrix();
    glRotatef(anglee, 0.0f, 0.0f, 0.0f);
    glTranslatef(0.0,20.0,8);
    glutSolidSphere(0.4,50,50);
glPopMatrix();
anglee+=4.0f;
}

I have got the first rotation correct, but i am not sure how to go about the second rotation.

  • 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-14T04:00:54+00:00Added an answer on June 14, 2026 at 4:00 am

    Here’s a hint.. do this in your display callback function:

    void display()
    {
        glClearColor(0,0,0,0);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glLoadIdentity();
        gluLookAt(10,10,10, 0,0,0, 0,1,0);
    
        /* current position is by default the origin */
    
        //draw sun
        glutSolidSphere(1,100,100);
    
        //draw planet
        glRotated(angle1,0,1,0);        //rotates position by angle1
        glTranslated(0,0,5);            //translates position by sun-planet distance
        glutSolidSphere(0.7,100,100);   //draw planet at this new position
    
        //draw moon
        glRotated(angle2,0,1,0);        //rotates position by angle1+angle2
        glTranslated(0,0,2);            //translates position by planet-moon distance
        glutSolidSphere(0.3,100,100);   //draw moon at this new position
    
        glutSwapBuffers();
    
        angle1 += 0.2;
        angle2 += 0.2;
        if(angle1 > 360) angle1 = 0;
        if(angle2 > 360) angle2 = 0;
    }
    

    Try commenting some lines from both the draw planet and moon parts and see the difference, will help you understand it.

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to create rotating object using jQuery and without any other
When we rotate any object like Image then its x and y will also
I have a little issue, I'm rotating an object. I want rounded values for
I have a problem with rotating. I know that I can rotate a Texture2D
Programming language: Java Ok, so I want to have a BufferedImage that keeps rotating
Right now I'm rotating an object, lets call it 'mainBody' but attached to the
I have a spotlight that moves on a stage. Now I rotate the spotlight
How can I make an object rotate around its axis? i.e. having the moon
I have some rotating images with hidden captions that I'd like to expose with
I have a problem with a UIView-subclass object that I am rotating using Core

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.