PrusaSlicer-NonPlainar/xs/src/Point.hpp

40 lines
939 B
C++
Raw Normal View History

2013-07-06 13:26:32 +00:00
#ifndef slic3r_Point_hpp_
#define slic3r_Point_hpp_
extern "C" {
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
}
2013-07-11 16:55:51 +00:00
#include <math.h>
2013-07-06 13:26:32 +00:00
class Point
{
public:
unsigned long x;
unsigned long y;
2013-07-06 14:33:49 +00:00
Point(unsigned long _x = 0, unsigned long _y = 0): x(_x), y(_y) {};
2013-07-11 16:55:51 +00:00
void rotate(double angle, Point* center);
2013-07-06 13:26:32 +00:00
};
2013-07-11 16:55:51 +00:00
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) );
}
2013-07-06 14:39:22 +00:00
SV*
point2perl(Point& point) {
AV* av = newAV();
av_fill(av, 1);
av_store_point_xy(av, point.x, point.y);
return sv_bless(newRV_noinc((SV*)av), gv_stashpv("Slic3r::Point", GV_ADD));
2013-07-06 14:39:22 +00:00
}
2013-07-06 13:26:32 +00:00
#endif