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 3877138
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:27:47+00:00 2026-05-19T22:27:47+00:00

Using openGL (just 2d), I’m trying to rotate a texture so it’s pointing towards

  • 0

Using openGL (just 2d), I’m trying to rotate a texture so it’s pointing towards a point on screen. I’ll show an image first to help me explain.

http://img692.imageshack.us/img692/3088/probe.png

Say my texture is the blue dot at point 1 and it is moving to its destination at point 2. I want to rotate #1 so that it is “pointing” towards point 2 (the texture is a bird so it has a defined “front”). To do this, I need to find out angle 3. Similarly, if my bird is at point #4 travelling towards point 5, I need to work out angle 6.

What’s the secret to doing this?

  • 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-05-19T22:27:47+00:00Added an answer on May 19, 2026 at 10:27 pm

    The solution is the super-useful std::atan2 function. Subtract the current position from the target position of a bird, and stuff y and x (note the order!) into atan2 to get the angle.

    Edit: Note that atan usually assumes 0° to be at the X+ axis (right). However, you seem to align your ‘base direction’ to Y+ instead (up), so you might want to subtract 90° or fiddle with the order and signs of parameters to the atan functions (using the basic symmetries in a circle, i.e. atan2(-x,y)).

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

Sidebar

Related Questions

I need to render quite alot (tens of thousands) images off-screen using OpenGL. I
I need to display 2d images in opengl using textures. The image dimensions are
I'm trying to load a texture with RGBA values but the alpha values just
What I'm trying to do is output a masked texture on an iPhone using
I'm using QImage.save to save an image of my OpenGL framebuffer to disk. If
I've been using OpenGL extensions on Windows the painful way . Is GLEW the
I'm using OpenGL ES on a low-resolution, embedded device . I've applied a vertical
In relation to this question on Using OpenGL extensions , what's the purpose of
I am working on a 2D game using OpenGL ES. I am using the
I've been programming opengl using glut as my window handler, lately i've been thinking

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.