2
\$\begingroup\$

I know that the easiest way to move an object with the figure 8 trajectory is:

x = cos(t);
y = sin(2*t) / 2;

but I just don't know how to rotate it, lets says with a new variable r as rotation, how do I merge it into the above formula ? can anyone please advise me on what is the simplest and cheapest way/formula to move and rotate the figure 8 trajectory ?

ref:How can I move an object in an "infinity" or "figure 8" trajectory?

\$\endgroup\$
5
\$\begingroup\$

The object should point in the direction of the derivative, which is [-sin(t), cos(2t)]. Its angle is atan2(cos(2t), -sin(t)).

Edit: OP is apparently asking how to rotate the "trajectory," not the object itself.

To rotate the figure, choose an angle, θ, in radians, that you'd like the trajectory to be rotated. The position along this rotated figure is:

x = cos(θ) * cos(t) - sin(θ) * sin(2t)/2
y = sin(θ) * cos(t) + cos(θ) * sin(2t)/2
\$\endgroup\$
  • \$\begingroup\$ so how would I modify the formula to get a rotated figure of 8 ? \$\endgroup\$ – user1998844 Mar 3 '17 at 18:24
  • \$\begingroup\$ That is a completely different question than the one I answered. I'll edit my answer with a solution to this question. \$\endgroup\$ – Drew Cummins Mar 3 '17 at 18:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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