Segment

open class Segment : Composite

Bounded line segment between its endpoints.

A Composite wrapping the Dipole of its endpoints and forwarding its algebra accessors; toDipole is the bridge back to pure CGA, symmetric with Dipole.toSegment. Geometric answers against a Segment respect its bounds — the chord itself, not the infinite carrier — while answers against the wrapped blade stay total.

The endpoint constructors keep the RoundPoint instances they are given: start/end return exactly those objects, so composites built on shared vertices (Polygon's edges) share them by reference. Identity is blade-based: equals/hashCode compare the wrapped dipoles, rounded at the SCALE quantum and orientation-sensitive (canonical for unoriented equivalence).

Constructors

Link copied to clipboard
constructor(start: FlatPoint, end: FlatPoint)

Builds the segment between two flat points.

constructor(start: RoundPoint, end: RoundPoint)

Builds the segment between two round points.

Properties

Link copied to clipboard

The direction from start toward end — a round point at infinity; see Dipole.attitude.

Link copied to clipboard
open val canonical: Segment

The canonical representative of this segment — useful for unoriented equivalence.

Link copied to clipboard

The line through both endpoints; see Dipole.carrier.

Link copied to clipboard

The midpoint of the endpoints — degenerates at infinity; see Dipole.center.

Link copied to clipboard

The perpendicular bisector of the endpoints; see Dipole.cocarrier.

Link copied to clipboard

The smallest circle containing this segment — the endpoints as a diameter; see Dipole.container.

Link copied to clipboard

The second endpoint.

Link copied to clipboard
val gx: Double

The e23 component — the carrier line's unit-normal x-component when finite; see Dipole.gx.

Link copied to clipboard
val gy: Double

The e31 component — the carrier line's unit-normal y-component when finite; see Dipole.gy.

Link copied to clipboard
val gz: Double

The e12 component — the carrier line's signed origin distance when finite; see Dipole.gz.

Link copied to clipboard

Whether this segment is imaginary — a negative squared radius, no real endpoints.

Link copied to clipboard

The distance between the segment's endpoints for a real segment — twice radius, raw and non-negative.

Link copied to clipboard
val px: Double

The e41 component of the flat bulk; see Dipole.px.

Link copied to clipboard
val py: Double

The e42 component of the flat bulk; see Dipole.py.

Link copied to clipboard
val pz: Double

The e43 component — minus the center's signed offset along attitude when finite; see Dipole.pz.

Link copied to clipboard

Half the distance between the endpoints for a real segment — raw, non-negative.

Link copied to clipboard

The squared half-distance between the endpoints — raw and signed; negative for an imaginary segment.

Link copied to clipboard

The first endpoint.

Link copied to clipboard

The wrapped Dipole — the bridge back to pure CGA.

Functions

Link copied to clipboard
open fun copy(segment: Segment): Segment

Returns this object rebuilt around the replacement geometry segment — the hook the shape-preserving operations return through.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean

Rounded, orientation-sensitive identity: equal when the wrapped dipoles are equal.

Link copied to clipboard
open override fun hashCode(): Int

Returns the wrapped dipole's hash — rounded, consistent with equals.

Link copied to clipboard
infix fun Segment.intersects(polygon: Polygon): Boolean

Segment intersects Polygon => Boolean
Returns whether the segment touches the polygon's boundary or lies within its solid region.

infix fun Segment.intersects(other: Segment): Boolean

Segment intersects Segment => Boolean
Returns whether the segments touch, cross, or overlap, endpoints included.

infix fun Segment.intersects(line: Line): Boolean

Segment intersects Line => Boolean
Returns whether the line touches or crosses the segment.

Link copied to clipboard
infix fun Segment.join(point: RoundPoint): Circle

Segment join RoundPoint => Circle
Returns the circle through the segment's endpoints and point.

Link copied to clipboard
infix fun Segment.meet(other: Segment): RoundPoint?

Segment meet Segment => RoundPoint?
Returns the point where the two segments cross, or null when they don't.

infix fun Segment.meet(line: Line): RoundPoint?

Segment meet Line => RoundPoint?
Returns the point where the line crosses the segment, or null when it misses.

Link copied to clipboard
open override fun toString(): String

Returns the endpoints at raw precision — full stored values, no rounding.

Link copied to clipboard

Returns the endpoints rounded at the SCALE quantum — the debug-output convention of every shape.