Uranium
Application Framework
Loading...
Searching...
No Matches
UM.Math.LineSegment.LineSegment Class Reference

Represents a line segment in 2D. More...

Public Member Functions

 __init__ (self, Vector2 endpoint_a, Vector2 endpoint_b)
 Creates a new line segment with the specified endpoints.
 
Vector2 getEnd (self)
 Gets the second endpoint (B) of the line segment.
 
Vector2 getStart (self)
 Gets the first endpoint (A) of the line segment.
 
Optional[Vector2intersection (self, "LineSegment" other)
 Returns the point of intersection of this line segment with another line segment, if any.
 
bool intersectsWithLine (self, Vector2 a, Vector2 b)
 Returns whether the line segment intersects the specified (infinite) line.
 

Protected Member Functions

bool _pointIsRight (self, Vector2 p, Vector2 a, Vector2 b)
 Determines whether point p is to the right of the line through a and b.
 

Protected Attributes

 _endpoint_a
 
 _endpoint_b
 

Detailed Description

Represents a line segment in 2D.

The line segment is represented by two endpoints.

Constructor & Destructor Documentation

◆ __init__()

UM.Math.LineSegment.LineSegment.__init__ (   self,
Vector2  endpoint_a,
Vector2  endpoint_b 
)

Creates a new line segment with the specified endpoints.

Parameters
endpoint_aAn endpoint of the line segment.
endpoint_bAn endpoint of the line segment.

Member Function Documentation

◆ _pointIsRight()

bool UM.Math.LineSegment.LineSegment._pointIsRight (   self,
Vector2  p,
Vector2  a,
Vector2  b 
)
protected

Determines whether point p is to the right of the line through a and b.

Parameters
pThe point to determine whether it is to the right of the line.
aA point on the line.
bAnother point on the line.

◆ getEnd()

Vector2 UM.Math.LineSegment.LineSegment.getEnd (   self)

Gets the second endpoint (B) of the line segment.

Returns
The second endpoint of the line segment.

◆ getStart()

Vector2 UM.Math.LineSegment.LineSegment.getStart (   self)

Gets the first endpoint (A) of the line segment.

Returns
The first endpoint of the line segment.

◆ intersection()

Optional[Vector2] UM.Math.LineSegment.LineSegment.intersection (   self,
"LineSegment"  other 
)

Returns the point of intersection of this line segment with another line segment, if any.

Parameters
otherThe line segment to check intersection with.
Returns
The intersection point if they intersect, or None otherwise.

◆ intersectsWithLine()

bool UM.Math.LineSegment.LineSegment.intersectsWithLine (   self,
Vector2  a,
Vector2  b 
)

Returns whether the line segment intersects the specified (infinite) line.

If the line segment touches the line with one or both endpoints, that counts as an intersection too.

Parameters
aA point on the line to intersect with.
bA different point on the line to intersect with.
Returns
True if the line segment intersects with the line, or False otherwise.

The documentation for this class was generated from the following file: