Package toxi.geom
Class Line2D
java.lang.Object
toxi.geom.Line2D
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
ConstructorDescriptionLine2D
(float x1, float y1, float x2, float y2) Line2D
(ReadonlyVec2D a, ReadonlyVec2D b) -
Method Summary
Modifier and TypeMethodDescriptionfloat
Computes the dot product of these 2 vectors: line start -> point and the perpendicular line direction.Computes the closest point on this line to the point given.copy()
float
float
boolean
Returns the line's bounding rect.float
float
float
boolean
hasEndPoint
(Vec2D p) int
hashCode()
Computes a hash code ignoring the directionality of the line.int
Computes the hash code for this instance taking directionality into account.Computes intersection between this and the given line.offsetAndGrowBy
(float offset, float scale, Vec2D ref) scaleLength
(float scale) splitIntoSegments
(List<Vec2D> segments, float stepLength, boolean addFirst) splitIntoSegments
(Vec2D a, Vec2D b, float stepLength, List<Vec2D> segments, boolean addFirst) Splits the line between A and B into segments of the given length, starting at point A.toRay2D()
toString()
-
Field Details
-
a
-
b
-
-
Constructor Details
-
Line2D
public Line2D(float x1, float y1, float x2, float y2) -
Line2D
-
Line2D
-
-
Method Details
-
splitIntoSegments
public static final List<Vec2D> splitIntoSegments(Vec2D a, Vec2D b, float stepLength, List<Vec2D> segments, boolean addFirst) Splits the line between A and B into segments of the given length, starting at point A. The tweened points are added to the given result list. The last point added is B itself and hence it is likely that the last segment has a shorter length than the step length requested. The first point (A) can be omitted and not be added to the list if so desired.- Parameters:
a
- start pointb
- end point (always added to results)stepLength
- desired distance between pointssegments
- existing array list for results (or a new list, if null)addFirst
- false, if A is NOT to be added to results- Returns:
- list of result vectors
-
classifyPoint
Computes the dot product of these 2 vectors: line start -> point and the perpendicular line direction. If the result is negative- Parameters:
p
-- Returns:
- classifier float
-
closestPointTo
Computes the closest point on this line to the point given.- Parameters:
p
- point to check against- Returns:
- closest point on the line
-
copy
-
distanceToPoint
-
distanceToPointSquared
-
equals
-
getBoundingCircle
-
getBounds
Returns the line's bounding rect.- Returns:
- bounding rect
-
getDirection
-
getHeading
public float getHeading() -
getLength
public float getLength() -
getLengthSquared
public float getLengthSquared() -
getMidPoint
-
getNormal
-
hasEndPoint
-
hashCode
public int hashCode()Computes a hash code ignoring the directionality of the line. -
hashCodeWithDirection
public int hashCodeWithDirection()Computes the hash code for this instance taking directionality into account. A->B will produce a different hash code than B->A. If directionality is not required or desired use the defaulthashCode()
method.- Returns:
- hash code
- See Also:
-
intersectLine
Computes intersection between this and the given line. The returned value is aLine2D.LineIntersection
instance and contains both the type of intersection as well as the intersection points (if existing). The intersection points are ALWAYS computed for the types INTERSECTING and NON_INTERSECTING. In the latter case the points will lie outside the two given line segments and constitute the intersections of the infinite versions of each line. Based on: http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/- Parameters:
l
- line to intersect with- Returns:
- intersection result
-
offsetAndGrowBy
-
scaleLength
-
set
-
splitIntoSegments
-
toRay2D
-
toString
-