ExPolygon::XS->rotate()
This commit is contained in:
@@ -8,14 +8,26 @@ extern "C" {
|
||||
#include "ppport.h"
|
||||
}
|
||||
|
||||
#include <math.h>
|
||||
|
||||
class Point
|
||||
{
|
||||
public:
|
||||
unsigned long x;
|
||||
unsigned long y;
|
||||
Point(unsigned long _x = 0, unsigned long _y = 0): x(_x), y(_y) {};
|
||||
void rotate(double angle, Point* center);
|
||||
};
|
||||
|
||||
void
|
||||
Point::rotate(double angle, Point* center)
|
||||
{
|
||||
double cur_x = (double)x;
|
||||
double cur_y = (double)y;
|
||||
x = (unsigned long)( (double)center->x + cos(angle) * (cur_x - (double)center->x) - sin(angle) * (cur_y - (double)center->y) );
|
||||
y = (unsigned long)( (double)center->y + cos(angle) * (cur_y - (double)center->y) + sin(angle) * (cur_x - (double)center->x) );
|
||||
}
|
||||
|
||||
SV*
|
||||
point2perl(Point& point) {
|
||||
AV* av = newAV();
|
||||
|
||||
Reference in New Issue
Block a user