Well, your object is represented by some initial coordinates (x, y) ^ t. To rotate this in 2D space you have to use a rotation matrix
R = [ cos(a) -sin(a)] [ sin(a) cos(a) ]
Since you also want to perform the T translation (moving along a sine wave), you can compose an affine transformation by expanding 2D coordinates to three-dimensional homogeneous coordinates. Suppose your translation is (tx, ty) and your rotation angle (in radians) is a, the transformation matrix will be
T = [ cos(a) -sin(a) tx sin(a) cos(a) ty 0 0 1 ]
When you convert the original (x, y) point to (x, y, 1), simple
T * (x,y,1)^t
will do the trick.
You can return from homogeneous to Cartesian coordinates by dividing all the elements into the last (i.e. you will lose one dimension). Since in this simple case they are always 1, you can simply delete the last coordinate and return to 2D.
Edit: Muting T and (x, y, 1) ^ t gives:
T*(x,y,1)^t = [ cos(a) -sin(a) tx ] [ x ] [ sin(a) cos(a) ty ]*[ y ] = [ 0 0 1 ] [ 1 ] = [ cos(a)*x - sin(a)*y + tx ] [ sin(a)*x + cos(a)*y + ty ] = [ 1 ] = (cos(a)*x - sin(a)*y + tx, sin(a)*x + cos(a)*y + ty, 1)^t
source share