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

The Archive Base Latest Questions

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

How would you go about mapping mouse coordinates to world coordinates in a 2d

  • 0

How would you go about mapping mouse coordinates to world coordinates in a 2d context?

For example, you have an image which you can drag. Next, you apply a rotation to that image and redraw it. Now when you drag the image it does not get translated correctly. For example after rotating 90 degrees, dragging up would cause the image to translate to the right.

Any ideas?

Currently attempting to rotate the mouse coordinates like so:

mouseX = ((mouseX*Math.cos(rotation*180/Math.PI))-(mouseY*Math.sin(rotation*180/Math.PI))),
mouseY = ((mouseX*Math.sin(rotation*180/Math.PI))+(mouseY*Math.cos(rotation*180/Math.PI)))

But this doesn’t seem to be working…

  • 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-15T02:19:28+00:00Added an answer on May 15, 2026 at 2:19 am

    You’ve got some image that lives in world coordinates, and you’re applying an affine transformation (composition of rotations, translations, and scaling) to it to get what it looks like on the screen:

    World ——-[affine transformation]——-> Screen

    Now if you want to map something that’s in screen coordinates (for instance, mouse cursor position) to world coordinates, you need to use the inverse of that affine transformation.

    If your transformation is just a rotation, as in your code snippet, negative rotation will do the trick.

    In general, you’ll want to represent your transformation and its inverse as 3×3 matrices A and A^-1. If W and S are world and screen affine coordinates, you have
    S = AW and W = A^1 S.

    To add on another transformation T to A, multiply A on the left by T and A^-1 on the right by T^-1:

    A = TA
    A^-1 = A^-1 T^-1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering how I would go about mapping 2D screen coordinates to a
Anyone have any idea how I would go about converting a timestamp in milliseconds
Does anyone know how I would go about changing (transforming) an image based on
I have created several Q about correctly mapping a website with a database so
I have been googling a lot about this, but I can't find a specific
How would I go about mapping three classes to one table with fluent NHibernate.
Using knockout's mapping plugin, how would I go about displaying the information from and
we have question about inheritance in PostgreSQL and mapping it as entities in JPA.
How would I go about mapping the following in NHibernate? My entities and ERD
Again I would like to get your opinion about a design issue. I have

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.