Fixed type error
This commit is contained in:
parent
f5a5eb3736
commit
660b56acb5
@ -182,14 +182,14 @@ Line::extend_start(double distance)
|
||||
bool
|
||||
Line::intersection(const Line& line, Point* intersection) const
|
||||
{
|
||||
double denom = ((line.b.y - line.a.y)*(this->b.x - this->a.x)) -
|
||||
((line.b.x - line.a.x)*(this->b.y - this->a.y));
|
||||
double denom = ((double)(line.b.y - line.a.y)*(this->b.x - this->a.x)) -
|
||||
((double)(line.b.x - line.a.x)*(this->b.y - this->a.y));
|
||||
|
||||
double nume_a = ((line.b.x - line.a.x)*(this->a.y - line.a.y)) -
|
||||
((line.b.y - line.a.y)*(this->a.x - line.a.x));
|
||||
double nume_a = ((double)(line.b.x - line.a.x)*(this->a.y - line.a.y)) -
|
||||
((double)(line.b.y - line.a.y)*(this->a.x - line.a.x));
|
||||
|
||||
double nume_b = ((this->b.x - this->a.x)*(this->a.y - line.a.y)) -
|
||||
((this->b.y - this->a.y)*(this->a.x - line.a.x));
|
||||
double nume_b = ((double)(this->b.x - this->a.x)*(this->a.y - line.a.y)) -
|
||||
((double)(this->b.y - this->a.y)*(this->a.x - line.a.x));
|
||||
|
||||
if (fabs(denom) < EPSILON) {
|
||||
if (fabs(nume_a) < EPSILON && fabs(nume_b) < EPSILON) {
|
||||
|
@ -5,7 +5,7 @@ use warnings;
|
||||
|
||||
use List::Util qw(first);
|
||||
use Slic3r::XS;
|
||||
use Test::More tests => 20;
|
||||
use Test::More tests => 21;
|
||||
|
||||
use constant PI => 4 * atan2(1, 1);
|
||||
|
||||
@ -73,6 +73,17 @@ ok $cw_polygon->contains_point(Slic3r::Point->new(150,150)), 'cw contains_point'
|
||||
is_deeply $polygon->centroid->pp, [150,150], 'centroid';
|
||||
}
|
||||
|
||||
{
|
||||
my $polygon = Slic3r::Polygon->new(
|
||||
[50000000, 100000000],
|
||||
[300000000, 102000000],
|
||||
[50000000, 104000000],
|
||||
);
|
||||
my $line = Slic3r::Line->new([175992032,102000000], [47983964,102000000]);
|
||||
my $intersection = $polygon->intersection($line);
|
||||
is_deeply $intersection->pp, [50000000, 102000000], 'polygon-line intersection';
|
||||
}
|
||||
|
||||
# this is not a test: this just demonstrates bad usage, where $polygon->clone gets
|
||||
# DESTROY'ed before the derived object ($point), causing bad memory access
|
||||
if (0) {
|
||||
|
@ -42,6 +42,12 @@
|
||||
std::string wkt();
|
||||
Points concave_points(double angle);
|
||||
Points convex_points(double angle);
|
||||
Clone<Point> intersection(Line* line)
|
||||
%code{%
|
||||
Point p;
|
||||
(void)THIS->intersection(*line, &p);
|
||||
RETVAL = p;
|
||||
%};
|
||||
%{
|
||||
|
||||
Polygon*
|
||||
|
Loading…
Reference in New Issue
Block a user