# What is the correct way to get the starting point of a Box2D body?

when I use getPosition() I get the center point of the body. The fixture's position in the body is relative to the body. However if the body is inclined and has an angle do I need to calculate the starting point of the body? I need this point to draw a sprite on it. Is there an easy way to do this?

• What is "the starting point" of a body? Coordinates that are closest to the origin of the world? Coordinates furthest from it? Something else? – Tyyppi_77 Apr 6 '17 at 12:15
• @Tyyppi_77 You know when I draw something on the canvas I need to know where to put this sprite. Say if I have a rectangle I need the top left point of the rectangle. If it is a line it is the left end of the line. – newguy Apr 6 '17 at 12:17
• You would need to rotate your sprite to be in sync with your box2d body/fixture. – jgallant Apr 6 '17 at 16:11
• @jgallant Thanks I figure out I need to anchor my sprite to its center and then rotate it to get the result. – newguy Apr 6 '17 at 16:38

Say that you want the vertex at L = (-w/2, -h/2), where w is the width of the rectangle and h is the height. Say that your box is at point P, rotated of an angle theta with respect to the axis orthogonal to the 2D plane.
First, get L' = R(theta) L, using the rotation matrix R(theta). This is the vector pointing at the desired corner, rotated according to the orientation of the box. Second, translate it with P, so that your desired point is X = P + L'.