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
Click For Summary
SUMMARY

The discussion focuses on rotating a 2D shape in C++ using mathematical formulas. The user seeks to rotate a line segment defined by points P1(-1,-1) and P2(1,1) by 45 degrees around the center point C(0,0). The correct transformation involves applying a rotation matrix, which results in the new coordinates P1(1,-1) and P2(-1,1). The reference link provided leads to a comprehensive guide on 2D point rotation.

PREREQUISITES
  • Understanding of 2D coordinate systems
  • Familiarity with C++ programming language
  • Knowledge of rotation matrices
  • Basic trigonometry, specifically sine and cosine functions
NEXT STEPS
  • Study the implementation of rotation matrices in C++
  • Learn about the use of the standard library for mathematical functions in C++
  • Explore the concept of translating shapes before and after rotation
  • Investigate graphical libraries in C++ such as SFML or SDL for 2D graphics
USEFUL FOR

Game developers, computer graphics programmers, and anyone interested in mastering 2D transformations in C++.

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).
 
Technology news on Phys.org
http://www.cgafaq.info/wiki/2D_Point_Rotation
 
Last edited by a moderator:
Ok thanks I got it.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 3 ·
Replies
3
Views
6K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 14 ·
Replies
14
Views
2K