Ported TriangleMesh->rotate
This commit is contained in:
parent
9402898c58
commit
d881c5ab2f
4 changed files with 14 additions and 1 deletions
|
@ -123,4 +123,11 @@ void TriangleMesh::align_to_origin()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TriangleMesh::rotate(double angle, Point* center)
|
||||||
|
{
|
||||||
|
this->translate(-center->x, -center->y, 0);
|
||||||
|
stl_rotate_z(&(this->stl), (float)angle);
|
||||||
|
this->translate(+center->x, +center->y, 0);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <myinit.h>
|
#include <myinit.h>
|
||||||
#include <admesh/stl.h>
|
#include <admesh/stl.h>
|
||||||
|
#include "Point.hpp"
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
|
@ -18,6 +19,7 @@ class TriangleMesh
|
||||||
void scale(float factor);
|
void scale(float factor);
|
||||||
void translate(float x, float y, float z);
|
void translate(float x, float y, float z);
|
||||||
void align_to_origin();
|
void align_to_origin();
|
||||||
|
void rotate(double angle, Point* center);
|
||||||
stl_file stl;
|
stl_file stl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use Slic3r::XS;
|
use Slic3r::XS;
|
||||||
use Test::More tests => 9;
|
use Test::More tests => 10;
|
||||||
|
|
||||||
is Slic3r::TriangleMesh::XS::hello_world(), 'Hello world!',
|
is Slic3r::TriangleMesh::XS::hello_world(), 'Hello world!',
|
||||||
'hello world';
|
'hello world';
|
||||||
|
@ -39,6 +39,9 @@ my $cube = {
|
||||||
is_deeply $m->vertices->[2], [0,0,0], 'align_to_origin';
|
is_deeply $m->vertices->[2], [0,0,0], 'align_to_origin';
|
||||||
|
|
||||||
is_deeply $m->size, [40,40,40], 'size';
|
is_deeply $m->size, [40,40,40], 'size';
|
||||||
|
|
||||||
|
$m->rotate(45, Slic3r::Point->new(20,20));
|
||||||
|
ok abs($m->size->[0] - sqrt(2)*40) < 1E-4, 'rotate';
|
||||||
}
|
}
|
||||||
|
|
||||||
__END__
|
__END__
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
void scale(float factor);
|
void scale(float factor);
|
||||||
void translate(float x, float y, float z);
|
void translate(float x, float y, float z);
|
||||||
void align_to_origin();
|
void align_to_origin();
|
||||||
|
void rotate(double angle, Point* center);
|
||||||
%{
|
%{
|
||||||
|
|
||||||
SV*
|
SV*
|
||||||
|
|
Loading…
Reference in a new issue