You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
Unfortunately, the Line::intersectsLine() method doesn't always work correctly. Try this test:
<?php
declare(strict_types=1);
require 'vendor/autoload.php';
use Location\Coordinate;
use Location\Line;
$line1 = new Line(
new Coordinate(0.0, 0.0),
new Coordinate(0.0, 2.0)
);
$line2 = new Line(
new Coordinate(2.0, 2.0),
new Coordinate(0.0, 10.0)
);
if ($line1->intersectsLine($line2)) {
echo 'Line::intersectsLine() is buggy!'.PHP_EOL;
}
The text was updated successfully, but these errors were encountered:
From a quick look at the source, in intersectsLine() we have these conditions:
// the lines are collinear or touchif (
in_array(self::ORIENTATION_COLLINEAR, $orientation, true)
&& (newIntersection())->intersects($this, $line, false)
) {
returntrue;
}
This only works if all points are collinear but fails if this is only true for three points (as in the example). So we would either have to switch to high precision for all calculations – (new Intersection())->intersects($this, $line, true) – or we would have to add a more precise condition that distinguises between three collinear points (setting precision to true) and four collinear points (settings precision to false).
Hello,
Unfortunately, the Line::intersectsLine() method doesn't always work correctly. Try this test:
The text was updated successfully, but these errors were encountered: