Package net.algart.math.geom
Class Segment2D
java.lang.Object
net.algart.math.geom.UnsafeSegment2D
net.algart.math.geom.Segment2D
- All Implemented Interfaces:
Cloneable
2D segment
This class is immutable and thread-safe: there are no ways to modify settings of the created instance.
- Author:
- Daniel Alievsky
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Should does nothing (unlike an implementation inUnsafeSegment2D
).void
copyFrom
(UnsafeSegment2D other) Sets the current segment identical to other.void
copyNormalTo
(Direction2D normal) Copies the normal vector to this segment to the given argument (normal.getAngle() will be equal to this.getFi() + π / 2).static Segment2D
Creates some "default" segment.static Segment2D
getInstance
(double centerX, double centerY, double length, double fi) Creates new segment; slowly, because requires sine and cosine calculation.static Segment2D
getInstance
(double centerX, double centerY, double length, Direction2D normal) Creates new segment.static Segment2D
getInstance
(UnsafeSegment2D instance) Creates new segment, identical to instance.Returns the normal unit vector, with creating a clone.void
setAll
(double centerX, double centerY, double length, double fi, double nx, double ny) Equivalent to setAll(centerX, centerY, length, fi) (nx and ny are ignored, unlike an implementation in UnsafeSegment2D).void
setFi
(double fi, double nx, double ny) Equivalent to setFi(fi) (nx and ny are ignored, unlike an implementation in UnsafeSegment2D).Methods inherited from class net.algart.math.geom.UnsafeSegment2D
clone, equals, getAngleBetweenDirections, getAngleBetweenStraights, getCenterX, getCenterY, getEqualityPrecision, getFi, getLength, getNormalUnitVectorX, getNormalUnitVectorY, getUnitVectorX, getUnitVectorY, getUnsafeInstance, getX1, getX2, getY1, getY2, hashCode, inverse, revive, rotate, rotateBack, setAll, setAll, setCenter, setCenterX, setCenterY, setEqualityPrecision, setFi, setLength, setNormal, toString
-
Method Details
-
getInstance
Creates some "default" segment. The parameters of this segment (center, orientation, length) are not specified. So, you must set all segment parameters after creating such instance. -
getInstance
Creates new segment, identical to instance. -
getInstance
Creates new segment; slowly, because requires sine and cosine calculation. -
getInstance
public static Segment2D getInstance(double centerX, double centerY, double length, Direction2D normal) Creates new segment. -
setFi
public void setFi(double fi, double nx, double ny) Equivalent to setFi(fi) (nx and ny are ignored, unlike an implementation in UnsafeSegment2D). This method works slowly, because requires sine and cosine calculation.- Overrides:
setFi
in classUnsafeSegment2D
-
setAll
public void setAll(double centerX, double centerY, double length, double fi, double nx, double ny) Equivalent to setAll(centerX, centerY, length, fi) (nx and ny are ignored, unlike an implementation in UnsafeSegment2D). This method works slowly, because requires sine and cosine calculation.- Overrides:
setAll
in classUnsafeSegment2D
-
getNormalClone
Description copied from class:UnsafeSegment2D
Returns the normal unit vector, with creating a clone.- Overrides:
getNormalClone
in classUnsafeSegment2D
-
copyNormalTo
Description copied from class:UnsafeSegment2D
Copies the normal vector to this segment to the given argument (normal.getAngle() will be equal to this.getFi() + π / 2).- Overrides:
copyNormalTo
in classUnsafeSegment2D
-
copyFrom
Description copied from class:UnsafeSegment2D
Sets the current segment identical to other.- Overrides:
copyFrom
in classUnsafeSegment2D
-
checkInvariants
public void checkInvariants()Should does nothing (unlike an implementation inUnsafeSegment2D
). However, it will generate InternalError if there are some bugs in this package.- Overrides:
checkInvariants
in classUnsafeSegment2D
-