0
$\begingroup$

I've been trying to solve for this a while now. What I am trying to do is to find the coordinates of a point on an object while it rotates. After digging around I have found the following equation which in it's basic form is what I want

x = x*cos(θ) - y*sin(θ) y = x*sin(θ) + y*cos(θ) 

With the screenshots below I've attached a white dot to the point I'm currently tracking which is really just the X Y of the red rectangle. As you can see assuming the middle screenshot is my starting point I want to have the white square be in the same spot regardless of rotation. Right now (because rotation isnt being taken into account) the white dot movies around on the rectangle as it rotates.

I know I need to take rotation into account but I'm not sure how to go about calculating it. This red rectangle moves about another object that is attached to a flexible joint so the coordinates of rotation aren't something particularly easy to come by. The rotation point of the red rectangle is center top, however.

Can anyone guide me in the right direction?

enter image description here

enter image description here

enter image description here

  • 0
    I guess that's the paradox of usi$n$g a physics engine. 99% of the work is done for you until you need to do something specific. The engine handles attaching objects in space via joints and other mechanics, and exposes coordinates, rotation angles etc.. So I have access to the coordinate of the rectangle and its rotation.2011-10-25

1 Answers 1

0

If this is all in 2D, you have the coordinates of a point on the object, and want the coordinates of another point on the object, you can call the position of the known point $(x_0,y_0)$ and the offset from the known point to your dot $(x_1,y_1)$ when the rotation is $0$. Then at any time your dot is at $(x_0+x_1 \cos \theta -y_1 \sin \theta,y_0+y_1 \cos \theta +x_1 \sin \theta)$, which is just applying your equations to the known point.

If this is 3D the same basic idea applies, but you need three coordinates and two angles to specify the position of your dot. If we measure the angles from when the dot is above the fixed point by distance $r$, the position is $(x_0+r\cos \phi \sin \theta,y_0+r\sin \phi \sin \theta,z_0+r\cos \theta)$ where $\theta$ is a rotation around $y$ and $\phi$ is a subsequent rotation around $z$

Is this the sort of thing you were after?

  • 0
    Then you can reverse the equations to determine where the other point on the rectangle has to be. Presumably that is the joint location.2011-10-25