Geometry
Exact symbolic plane geometry. Coordinates, lengths, and angles are
Expression values.
Constructors#
Constructing a geometry class directly uses the shared default context.
The matching Context method constructs the object in an explicit context.
point_2d#
Explicit context
fun point2d(
coordinateX: UniffiExpression,
coordinateY: UniffiExpression,
): UniffiPoint2d
segment_2d#
Explicit context
fun segment2d(start: UniffiPoint2d, end: UniffiPoint2d): UniffiSegment2d
polygon_2d#
Explicit context
fun polygon2d(vertices: List<UniffiPoint2d>): UniffiPolygon2d
Simple polygon from its vertex list in order; degenerate inputs raise.
triangle_2d#
Explicit context
fun triangle2d(
first: UniffiPoint2d,
second: UniffiPoint2d,
third: UniffiPoint2d,
): UniffiTriangle2d
Collinear vertices raise.
circle_2d#
Explicit context
fun circle2d(
center: UniffiPoint2d,
radius: UniffiExpression,
): UniffiCircle2d
point_2d methods#
UniffiPoint2d method
fun x(): UniffiExpression
The x coordinate of the point.
UniffiPoint2d method
fun y(): UniffiExpression
The y coordinate of the point.
coordinates#
UniffiPoint2d method
fun coordinates(): UniffiExpressionExpressionTuple
The (x, y) coordinate pair of the point.
distance_to#
Euclidean distance, exact (a sqrt expression in general).
UniffiPoint2d method
fun distanceTo(other: UniffiPoint2d): UniffiExpression
Euclidean distance, exact (a sqrt expression in general).
segment_2d methods#
length#
Also the finite-set length accessor on Expression in WASM; context
disambiguates.
UniffiSegment2d method
fun length(): UniffiExpression
Also the finite-set length accessor on expression in WASM; context disambiguates.
midpoint#
UniffiSegment2d method
fun midpoint(): UniffiPoint2d
Midpoint of the segment.
perpendicular_bisector_equation#
The bisector line as an equal relation in x and y.
UniffiSegment2d method
fun perpendicularBisectorEquation(
variableX: kotlin.String,
variableY: kotlin.String,
): UniffiExpression
The bisector line as an equal relation in x and y.
polygon_2d and triangle_2d#
area#
UniffiPolygon2d method
fun area(): UniffiExpression
Calling forms and variants
Variant for this object — UniffiTriangle2d method: UniffiTriangle2d.area
fun area(): UniffiExpression
For a Polygon2d or Triangle2d, this is the unsigned shoelace area of the
ordered boundary, so a polygon's orientation does not change its area. A
circle's area is a different formula under a different owner; see
Circle2d.area.
perimeter#
UniffiPolygon2d method
fun perimeter(): UniffiExpression
Calling forms and variants
Variant for this object — UniffiTriangle2d method: UniffiTriangle2d.perimeter
fun perimeter(): UniffiExpression
centroid#
UniffiPolygon2d method
fun centroid(): UniffiPoint2d
Calling forms and variants
Variant for this object — UniffiTriangle2d method: UniffiTriangle2d.centroid
fun centroid(): UniffiPoint2d
interior_angles#
UniffiPolygon2d method
fun interiorAngles(): List<UniffiVertexAngle>
Calling forms and variants
Variant for this object — UniffiTriangle2d method: UniffiTriangle2d.interiorAngles
fun interiorAngles(): List<UniffiVertexAngle>
Each vertex paired with its interior angle. Notes: WASM returns
VertexAngle objects with vertex/angle getters.
vertex_angle (WASM result class)#
vertex#
UniffiVertexAngle method
fun vertex(): UniffiPoint2d
The vertex the angle is measured at.
angle#
UniffiVertexAngle method
fun angle(): UniffiExpression
The interior angle at the vertex.
circle_2d methods#
center#
UniffiCircle2d method
fun center(): UniffiPoint2d
The center of the circle.
radius#
UniffiCircle2d method
fun radius(): UniffiExpression
The radius of the circle.
Circle2d.area#
UniffiCircle2d method
fun area(): UniffiExpression
The exact disk area πr2, from the circle's symbolic radius. This is not
the polygon and triangle shoelace operation of area above; the two
share a member name and nothing else.
circumference#
UniffiCircle2d method
fun circumference(): UniffiExpression
Circumference of the circle.
equation#
UniffiCircle2d method
fun equation(
variableX: kotlin.String,
variableY: kotlin.String,
): UniffiExpression
The circle as an equal relation in x and y.
Exact boundary intersections#
intersection#
UniffiPoint2d method
fun intersection(other: UniffiGeometry2d): List<UniffiGeometryIntersectionComponent>
Calling forms and variants
Variant for this object — UniffiCircle2d method: UniffiCircle2d.intersection
fun intersection(other: UniffiGeometry2d): List<UniffiGeometryIntersectionComponent>
Variant for this object — UniffiPolygon2d method: UniffiPolygon2d.intersection
fun intersection(other: UniffiGeometry2d): List<UniffiGeometryIntersectionComponent>
Variant for this object — UniffiSegment2d method: UniffiSegment2d.intersection
fun intersection(other: UniffiGeometry2d): List<UniffiGeometryIntersectionComponent>
Variant for this object — UniffiTriangle2d method: UniffiTriangle2d.intersection
fun intersection(other: UniffiGeometry2d): List<UniffiGeometryIntersectionComponent>
Every point, segment, polygon, triangle, and circle exposes the same symmetric
intersection method. Polygon and triangle operands mean their closed boundary;
circle operands mean their circumference. Isolated intersections are returned as
Point2d objects, while a shared edge or coincident circle is returned as the
corresponding Segment2d or Circle2d component instead of sampled points.
The component sequence is exact and deterministic. If any required symbolic
predicate cannot be decided, the operation declines instead of returning an
incomplete list. Both operands must belong to the same context.
Output#
All geometry classes also provide to_latex (and serialize_object in
WASM; Python serializes through Context.serializeObject).
Example#
Additional API#
Circle2d#
Circle2d.is_stale#
UniffiCircle2d method
fun isStale(): kotlin.Boolean
Reports whether resetting the owning context invalidated the expression. All other operations reject a stale receiver with an actionable error.
Point2d#
Point2d.is_stale#
UniffiPoint2d method
fun isStale(): kotlin.Boolean
Reports whether resetting the owning context invalidated the expression. All other operations reject a stale receiver with an actionable error.
Polygon2d#
Polygon2d.is_stale#
UniffiPolygon2d method
fun isStale(): kotlin.Boolean
Reports whether resetting the owning context invalidated the expression. All other operations reject a stale receiver with an actionable error.
Segment2d#
Segment2d.is_stale#
UniffiSegment2d method
fun isStale(): kotlin.Boolean
Reports whether resetting the owning context invalidated the expression. All other operations reject a stale receiver with an actionable error.
Triangle2d#
Triangle2d.is_stale#
UniffiTriangle2d method
fun isStale(): kotlin.Boolean
Reports whether resetting the owning context invalidated the expression. All other operations reject a stale receiver with an actionable error.