C#

Asked • 06/17/19

Proper Trigonometry For Rotating A Point Around The Origin?

Do either of the below approaches use the correct mathematics for rotating a point? If so, which one is correct? POINT rotate_point(float cx,float cy,float angle,POINT p) { float s = sin(angle); float c = cos(angle); // translate point back to origin: p.x -= cx; p.y -= cy; // Which One Is Correct: // This? float xnew = p.x * c - p.y * s; float ynew = p.x * s + p.y * c; // Or This? float xnew = p.x * c + p.y * s; float ynew = -p.x * s + p.y * c; // translate point back: p.x = xnew + cx; p.y = ynew + cy; }

1 Expert Answer

By:

Mike G. answered • 11/12/23

Tutor
New to Wyzant

Seasoned engineer with 20+ years experience in software

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.