java.lang.Object
uk.ac.leeds.ccg.v3d.core.V3D_Object
uk.ac.leeds.ccg.v3d.geometry.V3D_Geometry
uk.ac.leeds.ccg.v3d.geometry.V3D_Line
uk.ac.leeds.ccg.v3d.geometry.V3D_LineSegment
- All Implemented Interfaces:
java.io.Serializable,V3D_FiniteGeometry
- Direct Known Subclasses:
V3D_EnvelopeEdge
public class V3D_LineSegment extends V3D_Line implements V3D_FiniteGeometry
Class for a line segment in 3D represented by two Point3D instances. Two
instances are regarded as equal i they are represented by the same points
irrespective as which is assigned as
V3D_Line.p and which is assigned as
V3D_Line.q.- Version:
- 1.0
- Author:
- Andy Turner
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description protected V3D_EnvelopeenV3D_VectorunitVectorFor storing the unit vector.java.math.RoundingModeunitVectorRoundingModeUsed for calculating theunitVectorif necessary.intunitVectorScaleFor storing the scale at which theunitVectoris precise givenunitVectorRoundingMode. -
Constructor Summary
Constructors Constructor Description V3D_LineSegment(V3D_Line l)V3D_LineSegment(V3D_Point p, V3D_Point q) -
Method Summary
Modifier and Type Method Description booleanequals(java.lang.Object o)V3D_EnvelopegetEnvelope()V3D_GeometrygetIntersection(V3D_LineSegment l)Intersectsthiswithl.static V3D_GeometrygetIntersection(V3D_LineSegment l0, V3D_LineSegment l1)java.math.BigDecimalgetLength(int scale, java.math.RoundingMode rm)V3D_VectorgetUnitVector(int scale, java.math.RoundingMode rm)For getting the unit vector of this line toscaleprecision usingrmif necessary.inthashCode()V3D_VectorinitUnitVector(int scale, java.math.RoundingMode rm)For initialising and returning the unit vector of this line toscaleprecision usingrmif necessary.booleanisIntersectedBy(V3D_LineSegment l)booleanisIntersectedBy(V3D_Point p)V3D_LineSegmentmultiply(ch.obermuhlner.math.big.BigRational s)Methods inherited from class uk.ac.leeds.ccg.v3d.geometry.V3D_Line
getDistance, getIntersection, getIntersection, isIntersectedBy, isParallel, toString
-
Field Details
-
en
-
unitVector
For storing the unit vector. Only if the direction aligns with an axis is this precise. Otherwise the precision is given byunitVectorScale. -
unitVectorScale
public int unitVectorScaleFor storing the scale at which theunitVectoris precise givenunitVectorRoundingMode. -
unitVectorRoundingMode
public java.math.RoundingMode unitVectorRoundingModeUsed for calculating theunitVectorif necessary.
-
-
Constructor Details
-
V3D_LineSegment
- Parameters:
p- WhatV3D_Line.pis set to.q- WhatV3D_Line.qis set to.
-
V3D_LineSegment
- Parameters:
l- Vector_LineSegment3D
-
-
Method Details
-
equals
public boolean equals(java.lang.Object o) -
hashCode
public int hashCode() -
getUnitVector
For getting the unit vector of this line toscaleprecision usingrmif necessary.- Parameters:
scale- The scale for the precision of the result.rm- The RoundingMode for any rounding.- Returns:
- The unit vector of this line to
scaleprecision usingrmif necessary.
-
initUnitVector
For initialising and returning the unit vector of this line toscaleprecision usingrmif necessary.- Parameters:
scale- The scale for the precision of the result.rm- The RoundingMode for any rounding.- Returns:
- The unit vector of this line to
scaleprecision usingrmif necessary.
-
multiply
- Parameters:
s- The scaler value to multiply each coordinate of this by.- Returns:
- this multiplied by scalar
-
getLength
public java.math.BigDecimal getLength(int scale, java.math.RoundingMode rm)- Parameters:
scale- The scale for the precision of the result.rm- The RoundingMode for any rounding.- Returns:
- The length of this as a BigDecimal
-
getEnvelope
- Specified by:
getEnvelopein interfaceV3D_FiniteGeometry- Returns:
new V3D_Envelope(start, end)
-
isIntersectedBy
- Overrides:
isIntersectedByin classV3D_Line- Parameters:
p- A point to test for intersection within the specified tolerance.- Returns:
- true if p is within t of this given scale.
-
isIntersectedBy
- Parameters:
l- A line to test for intersection within the specified tolerance.- Returns:
- true if p is within t of this given scale.
-
getIntersection
Intersectsthiswithl. If they are equivalent then returnthis. If they overlap in a line return the part that overlaps (the order of points is not defined). If they intersect at a point, the point is returned.nullis returned if the two line segments do not intersect.- Parameters:
l- The line to get intersection with this.- Returns:
- The intersection between
thisandl.
-
getIntersection
-