- java.lang.Object
-
- org.arakhne.afc.math.geometry.d2.d.AbstractShape2d<Segment2d>
-
- org.arakhne.afc.math.geometry.d2.d.Segment2d
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Segment2afp<Shape2d<?>,Segment2d,PathElement2d,Point2d,Vector2d,Rectangle2d>
,Shape2afp<Shape2d<?>,Segment2d,PathElement2d,Point2d,Vector2d,Rectangle2d>
,Shape2d<Segment2d>
,Shape2D<Shape2d<?>,Segment2d,PathIterator2afp<PathElement2d>,Point2d,Vector2d,Rectangle2d>
,JsonableObject
public class Segment2d extends AbstractShape2d<Segment2d> implements Segment2afp<Shape2d<?>,Segment2d,PathElement2d,Point2d,Vector2d,Rectangle2d>
A 2D segment/line with 2 double precision floating-point numbers.- Since:
- 13.0
- Version:
- 17.0 2020-01-04 14:41:43
- Author:
- Stéphane GALLAND, Hamza JAFFALI
- See Also:
- Serialized Form
- Maven Group Id:
- org.arakhne.afc.core
- Maven Artifact Id:
- mathgeom
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.arakhne.afc.math.geometry.d2.afp.Segment2afp
Segment2afp.SegmentPathIterator<T extends PathElement2afp>, Segment2afp.UncertainIntersection
-
-
Constructor Summary
Constructors Constructor Description Segment2d()
Construct an empty segment.Segment2d(double x1, double y1, double x2, double y2)
Construct a segment from the two given points.Segment2d(Segment2afp<?,?,?,?,?,?> segment)
Constructor by copy.Segment2d(Point2D<?,?> p1, Point2D<?,?> p2)
Construct a segment from the two given points.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Segment2d
createTransformedShape(Transform2D transform)
Apply the transformation to the shape and reply the result.Point2d
getP1()
Replies the first point.Point2d
getP2()
Replies the second point.double
getX1()
Replies the X of the first point.double
getX2()
Replies the X of the second point.double
getY1()
Replies the Y of the first point.double
getY2()
Replies the Y of the second point.int
hashCode()
void
set(double x1, double y1, double x2, double y2)
Change the line.void
setX1(double x)
Sets a new value in the X of the first point.void
setX2(double x)
Sets a new value in the X of the second point.void
setY1(double y)
Sets a new value in the Y of the first point.void
setY2(double y)
Sets a new value in the Y of the second point.-
Methods inherited from class org.arakhne.afc.math.geometry.d2.d.AbstractShape2d
addShapeGeometryChangeListener, clone, equals, fireGeometryChange, getGeomFactory, removeShapeGeometryChangeListener, toJson, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.arakhne.afc.vmutil.json.JsonableObject
toJson
-
Methods inherited from interface org.arakhne.afc.math.geometry.d2.afp.Segment2afp
clear, clipToRectangle, contains, contains, contains, equalsToShape, getClosestPointTo, getClosestPointTo, getClosestPointTo, getClosestPointTo, getClosestPointTo, getClosestPointTo, getClosestPointTo, getClosestPointTo, getClosestPointTo, getClosestPointTo, getDistanceL1, getDistanceLinf, getDistanceSquared, getDistanceSquared, getFarthestPointTo, getLength, getLengthSquared, getPathIterator, intersects, intersects, intersects, intersects, intersects, intersects, intersects, intersects, intersects, intersects, isEmpty, set, set, setP1, setP1, setP2, setP2, toBoundingBox, transform, translate
-
Methods inherited from interface org.arakhne.afc.math.geometry.d2.afp.Shape2afp
contains, getClosestPointTo, getClosestPointTo, getDistanceSquared, getDistanceSquared, getDistanceSquared, getDistanceSquared, getDistanceSquared, getDistanceSquared, getDistanceSquared, getDistanceSquared, getDistanceSquared, getDistanceSquared, getGeomFactory, intersects, intersects, toBoundingBox, translate
-
Methods inherited from interface org.arakhne.afc.math.geometry.d2.Shape2D
clone, equalsToPathIterator, getDistance, getDistance, getPathIterator, operator_add, operator_and, operator_and, operator_minus, operator_multiply, operator_plus, operator_remove, operator_upTo
-
-
-
-
Constructor Detail
-
Segment2d
public Segment2d()
Construct an empty segment.
-
Segment2d
public Segment2d(Point2D<?,?> p1, Point2D<?,?> p2)
Construct a segment from the two given points.- Parameters:
p1
- first point.p2
- second point.
-
Segment2d
public Segment2d(Segment2afp<?,?,?,?,?,?> segment)
Constructor by copy.- Parameters:
segment
- the segment to copy.
-
Segment2d
public Segment2d(double x1, double y1, double x2, double y2)
Construct a segment from the two given points.- Parameters:
x1
- x coordinate of the first point.y1
- y coordinate of the first point.x2
- x coordinate of the second point.y2
- y coordinate of the second point.
-
-
Method Detail
-
hashCode
@Pure public int hashCode()
- Specified by:
hashCode
in classAbstractShape2d<Segment2d>
-
createTransformedShape
@Pure public Segment2d createTransformedShape(Transform2D transform)
Description copied from interface:Shape2D
Apply the transformation to the shape and reply the result. This function does not change the current shape.- Specified by:
createTransformedShape
in interfaceShape2afp<Shape2d<?>,Segment2d,PathElement2d,Point2d,Vector2d,Rectangle2d>
- Specified by:
createTransformedShape
in interfaceShape2D<Shape2d<?>,Segment2d,PathIterator2afp<PathElement2d>,Point2d,Vector2d,Rectangle2d>
- Parameters:
transform
- is the transformation to apply to the shape.- Returns:
- the result of the transformation.
-
set
public void set(double x1, double y1, double x2, double y2)
Description copied from interface:Segment2afp
Change the line.- Specified by:
set
in interfaceSegment2afp<Shape2d<?>,Segment2d,PathElement2d,Point2d,Vector2d,Rectangle2d>
- Parameters:
x1
- x coordinate of the first point.y1
- y coordinate of the first point.x2
- x coordinate of the second point.y2
- y coordinate of the second point.
-
setX1
public void setX1(double x)
Description copied from interface:Segment2afp
Sets a new value in the X of the first point.- Specified by:
setX1
in interfaceSegment2afp<Shape2d<?>,Segment2d,PathElement2d,Point2d,Vector2d,Rectangle2d>
- Parameters:
x
- the new value double x
-
setY1
public void setY1(double y)
Description copied from interface:Segment2afp
Sets a new value in the Y of the first point.- Specified by:
setY1
in interfaceSegment2afp<Shape2d<?>,Segment2d,PathElement2d,Point2d,Vector2d,Rectangle2d>
- Parameters:
y
- the new value double y
-
setX2
public void setX2(double x)
Description copied from interface:Segment2afp
Sets a new value in the X of the second point.- Specified by:
setX2
in interfaceSegment2afp<Shape2d<?>,Segment2d,PathElement2d,Point2d,Vector2d,Rectangle2d>
- Parameters:
x
- the new value double x
-
setY2
public void setY2(double y)
Description copied from interface:Segment2afp
Sets a new value in the Y of the second point.- Specified by:
setY2
in interfaceSegment2afp<Shape2d<?>,Segment2d,PathElement2d,Point2d,Vector2d,Rectangle2d>
- Parameters:
y
- the new value double y
-
getX1
@Pure public double getX1()
Description copied from interface:Segment2afp
Replies the X of the first point.- Specified by:
getX1
in interfaceSegment2afp<Shape2d<?>,Segment2d,PathElement2d,Point2d,Vector2d,Rectangle2d>
- Returns:
- the x of the first point.
-
getY1
@Pure public double getY1()
Description copied from interface:Segment2afp
Replies the Y of the first point.- Specified by:
getY1
in interfaceSegment2afp<Shape2d<?>,Segment2d,PathElement2d,Point2d,Vector2d,Rectangle2d>
- Returns:
- the y of the first point.
-
getX2
@Pure public double getX2()
Description copied from interface:Segment2afp
Replies the X of the second point.- Specified by:
getX2
in interfaceSegment2afp<Shape2d<?>,Segment2d,PathElement2d,Point2d,Vector2d,Rectangle2d>
- Returns:
- the x of the second point.
-
getY2
@Pure public double getY2()
Description copied from interface:Segment2afp
Replies the Y of the second point.- Specified by:
getY2
in interfaceSegment2afp<Shape2d<?>,Segment2d,PathElement2d,Point2d,Vector2d,Rectangle2d>
- Returns:
- the y of the second point.
-
getP1
public Point2d getP1()
Description copied from interface:Segment2afp
Replies the first point.- Specified by:
getP1
in interfaceSegment2afp<Shape2d<?>,Segment2d,PathElement2d,Point2d,Vector2d,Rectangle2d>
- Returns:
- the first point.
-
getP2
public Point2d getP2()
Description copied from interface:Segment2afp
Replies the second point.- Specified by:
getP2
in interfaceSegment2afp<Shape2d<?>,Segment2d,PathElement2d,Point2d,Vector2d,Rectangle2d>
- Returns:
- the second point.
-
-