How do I rotate a 2D shape in C++?

  • Context: C/C++ 
  • Thread starter Thread starter sarah22
  • Start date Start date
  • Tags Tags
    Rotating Shapes
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 6K views
sarah22
Messages
26
Reaction score
0
I'm creating a C++ 2D program to practice my 2D skills. I'm almost done with everything but I'm stuck on this crap. Is there any formula on how to rotate a shape?

Example:

I have a line P1(-1,-1) P2(1,1)

If I rotate it by 45 degrees, I'll get a P1(1,-1) P2(-1,1). By the way, it should not leave its center which is C(0,0).
 
Physics news on Phys.org
http://www.cgafaq.info/wiki/2D_Point_Rotation
 
Last edited by a moderator: