Math problem: getting coordinates from position and angle

let me start by stating that I'm terrible in math.

I'm trying to reposition and rotate a rectangular rectangular. However, I need to rotate the right-angled nick from a point that is not 0,0, but depending on how much its coordinates are shifted. I am sure that this does not make much sense, so I made a few sketches to explain what I need.

alt text

the image above shows 3 stages of a red rectangle moving from 0% to 100%. The X and Y coordinates of the red rectangle (at the top left of the red rectangle) move only as a percentage of the height of the blue rectangle.

alt text

red rectangle can rotate. focusing only on the middle example (“Distance -50%”) from above, where the red rectangle is moved at -50 the height of the blue rectangle, its new angular in the image above is now -45 º. he was rotated with 0, 0 points.

alt text

Now my problem is that I want its pivot point to reflect its position.

the red and blue rectangles are the same size but have the opposite width and height. Since the coordinates of the red rectangle 0.0 are now -50% of the height of the blue rectangle, and since they have the opposite width and height, I want the pivot point to be 50% of the width of the red rectangle (or 50% blue). the height of the rectangle, which is the same).

, angular 50% , , , , , X Y angular , .

+3
5

:

Method for determining position deltas from an off-center rotation.

+4

.

1.. , , (RP), , , , ​​ .

alt text

2. 4 , RP (0,0). , (RP x, RP y), 4 .

alt text

3. ( , ):

alt text

, 45 ° .

alt text

4. ( RP 4 ): alt text

, , :)

+4

, , , , .

, (x, y) d (0,0). :

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

, (a, b). , (a, b), , (0,0).

x' = (x-a)*cos(d) - (y-b)*sin(d) + a
y' = (x-a)*sin(d) + (y-b)*cos(d) + b

(x, y) d (a, b).

(a, b) , (x, y) . (x ', y') .

+3

O P angular, :

alt text
(: controlsheet.com)

angular X, :

alt text
(: controlsheet.com)

, angular, :

alt text
(: rulesheet.com)

0

, ? , "-25%" "" -25% "- , .

0

Source: https://habr.com/ru/post/1750865/


All Articles