Skip to content

LineSegment2D contains doesn't work reliable for some input #8

Closed
@ChristianLutz

Description

@ChristianLutz

Hello,

I stumbled over a problem regarding the contains method. Checking if a projection is part of a line (containsProjection) returns true, but calling contains with the projected point on the line returns false.

@Test
public void testLineContainsPoint() {
  LineSegment2D line = new LineSegment2D(-123707.89774439273, 157924.65808795238, -125829.21808795238, 155803.33774439275);
  Point2D point2d = new Point2D(-125034.27520951361, 157129.7152095136);
  Point2D projectedPoint = line.projectedPoint(point2d);
  assertEquals("Point need to be the same", new Point2D(-124768.55791617256, 156863.99791617255),  projectedPoint);
  assertTrue("Point is on line", line.containsProjection(point2d));
  assertTrue("Projected point has to be located on the line", line.contains(projectedPoint));
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions