A
A
Alexander2015-01-19 06:53:58
Game development
Alexander, 2015-01-19 06:53:58

How to find out the coordinates of points (vertices)?

Hello, tell me how to find the coordinates of two points of an object?
1d38e6fc06574d4baab2b6dcae8bce66.png
You need to find the points marked in orange, i.e. the center of the "top" (front) of the object and the center of its "bottom" (back).
Known about the object:

  1. center coordinates (c)
  2. rotation angle (a)
  3. "width" and "height"
  4. the coordinates of the upper left corner of the object, without taking into account its rotation, they are the coordinates of the cell in which the object is located. But this, it seems to me, is not useful in calculations.

I understand that this is done through cosine and sine, but I can’t figure out what to multiply by the co / sine of the angle of rotation =)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladlen Grachev, 2015-01-19
@wxmaper

Take the angle a positive, clockwise. That is, instead of the angle shown in the figure of -45 degrees, take 360-45. If it is known in advance that the angle is set within (-360; 360) , then you can simply take the angle 360+a . Although in fact only the lower limit is important, and it is possible to write a reduction of the value to this limit.
The front coordinate relative to the center is: (cos a * h/2; sin a * h/2) . To convert to absolute coordinates, do not forget to add the center coordinates to the relative ones.
The task coordinate can be calculated either similarly, taking the angle 180+a, or by taking the coordinates inverse to the coordinates of the translation. In absolute coordinates, respectively, it is enough to subtract the front coordinates from the center coordinates, since the front and back are symmetrical about the center.
Since you need to work with a line passing through the center along the object, the width and coordinates of the corners are not needed in the solution. h/2 is the distance from the center to one of the desired points.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question