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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:14:09+00:00 2026-05-26T12:14:09+00:00

I have a square (100px x 100px) with origin at 0,0 (upper left). When

  • 0

I have a square (100px x 100px) with origin at 0,0 (upper left).
When I move the mouse, lets say 10 pixel x and y, I move the origin according to displacement and then origin becomes 10,10, simple. Works fine!

When I rotate the square, my rotation function rotates it fine, but then, after the square is rotated, lets say 10 degrees, the origin point should be move accordingly to the rotation. And now, I have no idea of the formula I have to apply to make it append!

I wikipedia, but I tink it’s too complicated.

http://en.wikipedia.org/wiki/Angular_displacement

and

http://en.wikipedia.org/wiki/Cosine#Sine.2C_cosine.2C_and_tangent

Example: After a 90 deg rotation to the left, the origin is now at : lower left, now when I move the mouse to to right, the picture go UP!!!!

  • 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-26T12:14:10+00:00Added an answer on May 26, 2026 at 12:14 pm

    Suppose you have a figure and you want to rotate it by angle alpha and translate it so that point (cx, cy) of the figure gets to point (sx, sy) after the transformation.

    enter image description here

    The transformation is

    transformed_x = x*cos(alpha) - y*sin(alpha) + offset_x
    transformed_y = x*sin(alpha) + y*cos(alpha) + offset_y
    

    to compute desired offset_x and offset_y values you just need to put your requirement about (cx, cy) and (sx, sy) into the above equations:

    sx = cx*cos(alpha) - cy*sin(alpha) + offset_x
    sy = cx*sin(alpha) + cy*cos(alpha) + offset_y
    

    and now you can easily extract the offset values from that:

    offset_x = sx - cx*cos(alpha) + cy*sin(alpha)
    offset_y = sy - cx*sin(alpha) - cy*cos(alpha)
    

    To set up canvas transform for it you need just to call

    context.translate(sx - cx*Math.cos(alpha) + cy*Math.sin(alpha),
                      sy - cx*Math.sin(alpha) - cy*Math.cos(alpha));
    context.rotate(alpha);
    

    You can see a little demo of this formula following this link.

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

Sidebar

Related Questions

Lets say I have a non-square image.. If I increment the width and I
anyone have experience doing this? when i say imaginary i mean the square root
I have an image which is square 100px by 100px. Was wondering if there
Say I have a square from (0,0) to (z,z). Given a triangle within this
I have a 500 x 400px square with a 100px grid inside it. Now
I have a square 400 x 400 with a plane projection attached to it
I have 3 square. smallest square s3 is inside s2. s2 is in side
I have a 2 dimensional array forming a table: [color][number][shape ] ------------------------- [black][10 ][square
In a C++ physics simulation, I have a class called Circle, and Square. These
I have a square grid, for a turn based game ( grid is similar

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.