First of all you need to know what is a rotation matrix :
A rotation matrix is a matrix that is used to perform a rotation in Euclidean space. For matrix. rotates points in the XY-Cartesian plane counter-clockwise through an angle θ about the origin of the Cartesian coordinate system.
For example : to rotate through 180 degree ,
This above given matrix is called as rotation matrix . This matrix multiplication will give the new position of the initial point(or vector ) after rotation.
// rotate p by theta degrees CCW w.r.t origin (0, 0)
point rotate(point p, double theta) {
double rad = DEG_to_RAD(theta);
// multiply theta with PI / 180.0
return point(p.x * cos(rad) - p.y * sin(rad),
p.x * sin(rad) + p.y * cos(rad)); }
A rotation matrix is a matrix that is used to perform a rotation in Euclidean space. For matrix. rotates points in the XY-Cartesian plane counter-clockwise through an angle θ about the origin of the Cartesian coordinate system.
For example : to rotate through 180 degree ,
This above given matrix is called as rotation matrix . This matrix multiplication will give the new position of the initial point(or vector ) after rotation.
// rotate p by theta degrees CCW w.r.t origin (0, 0)
point rotate(point p, double theta) {
double rad = DEG_to_RAD(theta);
// multiply theta with PI / 180.0
return point(p.x * cos(rad) - p.y * sin(rad),
p.x * sin(rad) + p.y * cos(rad)); }
No comments:
Post a Comment