java.lang.Object
imagingbook.common.geometry.basic.LineSegment2d
- All Implemented Interfaces:
ShapeProducer
Described a 2D line segment defined by two end points. Instances are immutable.
-
Constructor Summary
ConstructorsConstructorDescriptionLineSegment2d
(double x1, double y1, double x2, double y2) Constructor for double coordinates.LineSegment2d
(int x1, int y1, int x2, int y2) Constructor for integer coordinates.LineSegment2d
(Pnt2d p1, Pnt2d p2) Constructor for arbitrary 2D points. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface imagingbook.common.geometry.shape.ShapeProducer
getShape, getShapes, getShapes
-
Constructor Details
-
LineSegment2d
Constructor for arbitrary 2D points.- Parameters:
p1
- first end pointp2
- second end point
-
LineSegment2d
Constructor for integer coordinates.- Parameters:
x1
- x-coordinate of first pointy1
- y-coordinate of first pointx2
- x-coordinate of second pointy2
- y-coordinate of second point
-
LineSegment2d
Constructor for double coordinates.- Parameters:
x1
- x-coordinate of first pointy1
- y-coordinate of first pointx2
- x-coordinate of second pointy2
- y-coordinate of second point
-
-
Method Details
-
getP1
Returns the first end point.- Returns:
- the first end point
-
getP2
Returns the second end point.- Returns:
- the second end point
-
getShape
Description copied from interface:ShapeProducer
Returns a scaledShape
for this object (default scale is 1). Must be defined by implementing classes. The interpretation of the scale factor is left to the implementing class. For example, forPnt2d
it specifies the size of the marker (seePnt2d.getShape(double)
.- Specified by:
getShape
in interfaceShapeProducer
- Parameters:
scale
- the scale of the shape- Returns:
- a
Shape
instance
-