Skip to content
Symi Docs
Swift
On this page

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

func point2d(
    coordinateX: UniffiExpression,
    coordinateY: UniffiExpression,
) -> UniffiPoint2d

segment_2d#

Explicit context

func segment2d(
    start: UniffiPoint2d,
    end: UniffiPoint2d,
) -> UniffiSegment2d

polygon_2d#

Explicit context

func polygon2d(vertices: [UniffiPoint2d]) -> UniffiPolygon2d

Simple polygon from its vertex list in order; degenerate inputs raise.

triangle_2d#

Explicit context

func triangle2d(
    first: UniffiPoint2d,
    second: UniffiPoint2d,
    third: UniffiPoint2d,
) -> UniffiTriangle2d

Collinear vertices raise.

circle_2d#

Explicit context

func circle2d(
    center: UniffiPoint2d,
    radius: UniffiExpression,
) -> UniffiCircle2d

point_2d methods#

x#

UniffiPoint2d method

func x() -> UniffiExpression

The x coordinate of the point.

y#

UniffiPoint2d method

func y() -> UniffiExpression

The y coordinate of the point.

coordinates#

UniffiPoint2d method

func coordinates() -> UniffiExpressionExpressionTuple

The (x, y) coordinate pair of the point.

distance_to#

Euclidean distance, exact (a sqrt expression in general).

UniffiPoint2d method

func 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

func length() -> UniffiExpression

Also the finite-set length accessor on expression in WASM; context disambiguates.

midpoint#

UniffiSegment2d method

func midpoint() -> UniffiPoint2d

Midpoint of the segment.

perpendicular_bisector_equation#

The bisector line as an equal relation in x and y.

UniffiSegment2d method

func perpendicularBisectorEquation(
    variableX: String,
    variableY: String,
) -> UniffiExpression

The bisector line as an equal relation in x and y.

polygon_2d and triangle_2d#

area#

UniffiPolygon2d method

func area() -> UniffiExpression
Calling forms and variants

Variant for this object — UniffiTriangle2d method: UniffiTriangle2d.area

func 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

func perimeter() -> UniffiExpression
Calling forms and variants

Variant for this object — UniffiTriangle2d method: UniffiTriangle2d.perimeter

func perimeter() -> UniffiExpression

centroid#

UniffiPolygon2d method

func centroid() -> UniffiPoint2d
Calling forms and variants

Variant for this object — UniffiTriangle2d method: UniffiTriangle2d.centroid

func centroid() -> UniffiPoint2d

interior_angles#

UniffiPolygon2d method

func interiorAngles() -> [UniffiVertexAngle]
Calling forms and variants

Variant for this object — UniffiTriangle2d method: UniffiTriangle2d.interiorAngles

func interiorAngles() -> [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

func vertex() -> UniffiPoint2d

The vertex the angle is measured at.

angle#

UniffiVertexAngle method

func angle() -> UniffiExpression

The interior angle at the vertex.

circle_2d methods#

center#

UniffiCircle2d method

func center() -> UniffiPoint2d

The center of the circle.

radius#

UniffiCircle2d method

func radius() -> UniffiExpression

The radius of the circle.

Circle2d.area#

UniffiCircle2d method

func area() -> UniffiExpression

The exact disk area πr2\pi r^2, 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

func circumference() -> UniffiExpression

Circumference of the circle.

equation#

UniffiCircle2d method

func equation(variableX: String, variableY: String) -> UniffiExpression

The circle as an equal relation in x and y.

Exact boundary intersections#

intersection#

UniffiPoint2d method

func intersection(other: UniffiGeometry2d) -> [UniffiGeometryIntersectionComponent]
Calling forms and variants

Variant for this object — UniffiCircle2d method: UniffiCircle2d.intersection

func intersection(other: UniffiGeometry2d) -> [UniffiGeometryIntersectionComponent]

Variant for this object — UniffiPolygon2d method: UniffiPolygon2d.intersection

func intersection(other: UniffiGeometry2d) -> [UniffiGeometryIntersectionComponent]

Variant for this object — UniffiSegment2d method: UniffiSegment2d.intersection

func intersection(other: UniffiGeometry2d) -> [UniffiGeometryIntersectionComponent]

Variant for this object — UniffiTriangle2d method: UniffiTriangle2d.intersection

func intersection(other: UniffiGeometry2d) -> [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

func isStale() -> Bool

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

func isStale() -> Bool

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

func isStale() -> Bool

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

func isStale() -> Bool

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

func isStale() -> Bool

Reports whether resetting the owning context invalidated the expression. All other operations reject a stale receiver with an actionable error.

Symi documentation · Swift