OiO.lk Blog javascript Calculate point coords relative to a rotated DIV
javascript

Calculate point coords relative to a rotated DIV


I have a rotated DIV within a non-rotated DIV and I’m trying to work out the cursor position on the outer DIV in relation to the rotated DIV. I guess I need the position as though the coordinate system has been rotated to match the angle of the rotated div.

Following is an example of what I need:

I know or can easily get:

  • w1, the width of the outer DIV
  • h1, the height of the outer DIV
  • w2, the width of the inner/rotated DIV
  • h2, the height of the inner/rotated DIV
  • a, the angle of the rotated DIV
  • x1, the x coord of a point P
  • y1, the y coord of a point P

I don’t know how to get, but need, x2 and y2.



You need to sign in to view this answers

Exit mobile version