Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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

share|improve this question
    
I think you'll need to tell us more about what you're currently doing to obtain these dots and rectangles, and how you'd want them to behave instead. –  joriki Oct 25 '11 at 3:19
    
I guess that's the paradox of using 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. –  methodin Oct 25 '11 at 3:58
add comment

1 Answer 1

up vote 0 down vote accepted

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?

share|improve this answer
    
I think you are kind of on the right track. I modified my question a tad to be more concise. Basically I want the white dot to always remain in the same spot as the second screenshot regardless of rotation. In the first it looks like the dot is in the same place as it would be if the rectangle was rotated 90 degrees to the right, but since I'm not taking the rotation into account it "moves around" as the rectangle rotates. –  methodin Oct 25 '11 at 3:56
    
Then you can reverse the equations to determine where the other point on the rectangle has to be. Presumably that is the joint location. –  Ross Millikan Oct 25 '11 at 4:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.