Coordinate translation on a rotating plane

Click For Summary
SUMMARY

The discussion addresses the challenge of converting mouse coordinates on a screen to relative coordinates on an object that undergoes translation, scaling, and rotation. Key variables include height (h), width (w), scalar (s), rotation angle (theta), and the rotation point (ox, oy). The provided formulas for calculating the unknown coordinates (ix, iy) involve trigonometric functions and highlight the importance of the order of operations in achieving accurate results. The consensus emphasizes that the sequence of rotation, scaling, and translation directly influences the final coordinate output.

PREREQUISITES
  • Understanding of trigonometric functions (sin, cos, acos, asin)
  • Familiarity with coordinate systems and transformations
  • Knowledge of scaling and rotation operations in 2D graphics
  • Experience with programming concepts for implementing mathematical formulas
NEXT STEPS
  • Research the order of transformations in 2D graphics programming
  • Explore the use of transformation matrices for scaling and rotation
  • Learn about the implications of coordinate normalization in graphical applications
  • Investigate libraries or frameworks that handle 2D transformations, such as p5.js or Processing
USEFUL FOR

Game developers, graphic designers, and software engineers working with 2D graphics who need to implement coordinate transformations effectively.

newjerseyrunner
Messages
1,532
Reaction score
637
I have this problem where I need to convert from mouse coordinates on the screen with relative coordinates on an object that can be arbitrarily translated, scaled, and rotated around another arbitrary position. I've already normalized all of the units to be the same (pixels) but the trig is eluding me right now.

h - height of normalized object
w - width of normalized object
s - scalar
theta - rotation angle
(ox, oy) - the point at which the object rotates
(x, y) - the point along absolute horizontal and vertical from the rotation point
(ix, iy) - the unknown

the blue line is the absolute horizontal, but it's value is arbitrary
theta, x, y, ix, iy, ox, and oy are real numbers
w, h, s are positive real numbers

image.jpg


ix = (ox * s + acos(90 - theta) * y + acos(theta) * x) / s;
iy = (oy * s + asin(90 - theta) * y + asin(theta) * x) / s;
Is that right?
 
Last edited:
Mathematics news on Phys.org
There are three operations being performed: rotation, scaling and translation. The result depends on the order of operations, and so the formula will also depend on that.

What is the order of the three operations?
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 16 ·
Replies
16
Views
5K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 20 ·
Replies
20
Views
4K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K