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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:01:20+00:00 2026-05-12T18:01:20+00:00

(This is all in ortho mode, origin is in the top left corner, x

  • 0

(This is all in ortho mode, origin is in the top left corner, x is positive to the right, y is positive down the y axis)

I have a rectangle in world space, which can have a rotation m_rotation (in degrees).

I can work with the rectangle fine, it rotates, scales, everything you could want it to do.

The part that I am getting really confused on is calculating the rectangles world coordinates from its local coordinates.

I’ve been trying to use the formula:

x' = x*cos(t) - y*sin(t) 
y' = x*sin(t) + y*cos(t)

where (x, y) are the original points,
(x', y') are the rotated coordinates,
and t is the angle measured in radians

from the x-axis. The rotation is
counter-clockwise as written. 
-credits duffymo

I tried implementing the formula like this:

//GLfloat Ax = getLocalVertices()[BOTTOM_LEFT].x * cosf(DEG_TO_RAD( m_orientation )) - getLocalVertices()[BOTTOM_LEFT].y * sinf(DEG_TO_RAD( m_orientation ));
//GLfloat Ay = getLocalVertices()[BOTTOM_LEFT].x * sinf(DEG_TO_RAD( m_orientation )) + getLocalVertices()[BOTTOM_LEFT].y * cosf(DEG_TO_RAD( m_orientation ));

//Vector3D BL = Vector3D(Ax,Ay,0);

I create a vector to the translated point, store it in the rectangles world_vertice member variable. That’s fine. However, in my main draw loop, I draw a line from (0,0,0) to the vector BL, and it seems as if the line is going in a circle from the point on the rectangle (the rectangles bottom left corner) around the origin of the world coordinates.

Basically, as m_orientation gets bigger it draws a huge circle around the (0,0,0) world coordinate system origin. edit: when m_orientation = 360, it gets set back to 0.

I feel like I am doing this part wrong:

and t is the angle measured in radians
from the x-axis.

Possibly I am not supposed to use m_orientation (the rectangles rotation angle) in this formula?

Thanks!

edit: the reason I am doing this is for collision detection. I need to know where the coordinates of the rectangles (soon to be rigid bodies) lie in the world coordinate place for collision detection.

  • 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-12T18:01:20+00:00Added an answer on May 12, 2026 at 6:01 pm

    What you do is rotation [ special linear transformation] of a vector with angle Q on 2d.It keeps vector length and change its direction around the origin.

    alt text

    [linear transformation : additive L(m + n) = L(m) + L(n) where {m, n} € vector , homogeneous L(k.m) = k.L(m) where m € vector and k € scalar ] So:

    You divide your vector into two pieces. Like m[1, 0] + n[0, 1] = your vector.
    Then as you see in the image, rotation is made on these two pieces, after that your vector take
    the form:

    m[cosQ, sinQ] + n[-sinQ, cosQ] = [mcosQ – nsinQ, msinQ + ncosQ]

    you can also look at Wiki Rotation

    If you try to obtain eye coordinates corresponding to your object coordinates, you should multiply your object coordinates by model-view matrix in opengl.

    For M => model view matrix and transpose of [x y z w] is your object coordinates you do:

    M[x y z w]T = Eye Coordinate of [x y z w]T

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

Sidebar

Related Questions

I'm probably doing this all wrong. I have a text file full of data
All the answers I've seen to this so far have confused me. I've made
I have been searching for this all over the internet, this site claims that
I've been messing with this all day and have still not found a solution.
I have been attempting this all morning (VS2K10, OL2K7, .NET 3.5) and my PSTs
I have been trying to do this all day. At the end i managed
Quick question. I have been Googling this all morning, but it's either not there,
Let's say I have model like this (all irrelevant fields removed for clarity): A(Model):
I've seen this all over the place: Download here! SHA1 = 8e1ed2ce9e7e473d38a9dc7824a384a9ac34d7d0 What does
I see this all the time in Ruby: require File.dirname(__FILE__) + /../../config/environment What does

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.