]> Shamusworld >> Repos - architektonas/blobdiff - src/geometry.cpp
Added rotation tool.
[architektonas] / src / geometry.cpp
index fdceb8eff6a332f618f83b2a334e6c38a84a4323..5f9a30b964f07348db24af44482508c52bacf668 100644 (file)
@@ -14,7 +14,7 @@
 //
 
 #include "geometry.h"
-
+#include <math.h>
 
 Point Geometry::IntersectionOfLineAndLine(Point p1, Point p2, Point p3, Point p4)
 {
@@ -76,3 +76,13 @@ Point Geometry::MirrorPointAroundLine(Point point, Point p1, Point p2)
        return mirroredPoint;
 }
 
+
+Point Geometry::RotatePointAroundPoint(Point point, Point rotationPoint, double angle)
+{
+       Vector v = Vector(point, rotationPoint);
+       double px = (v.x * cos(angle)) - (v.y * sin(angle));
+       double py = (v.x * sin(angle)) + (v.y * cos(angle));
+
+       return Vector(rotationPoint.x + px, rotationPoint.y + py, 0);
+}
+