S
S
Seva2019-06-12 17:26:25
JavaScript
Seva, 2019-06-12 17:26:25

How to rotate a shape?

Hello,
the task is to implement the rotation of the figure around its axis, similar to how in PowerPoint.
58872204-cc8c4400-86c3-11e9-84cf-e07ea8a
I'm trying to implement by analogy .
It does not work. The figure twitches, does not turn to the desired angle. What am I doing wrong?
JSFiddle
Thank you very much!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
profesor08, 2019-06-12
@profesor08

You need three points. The first is the starting position of the corner you're dragging, the second is the position of the pointer, and the third is the center of the shape. Determine the value of the angle of the center of the figure, there will be a value from 0 to 360. Thus, you will have to add (subtract) this value to the initial value of the rotation. If in radians, then convert to them accordingly. Determining the direction of movement of the pointer is not difficult, start from its initial position.

T
twobomb, 2019-06-12
@twobomb

Basically just take the angle between the pivot point, usually the center of the shape, and the mouse coordinates. Here is an example

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question