Geometry

public struct Geometry

Represents a geometry object.

  • Converts the specified angle from degrees to radians.

    Declaration

    Swift

    public static func radians(_ angle: Double) -> Double

    Parameters

    angle

    A double value, which specifies the angle in degrees.

    Return Value

    A double value, which specifies the angle in radians.

  • Converts the specified angle from radians to degrees.

    Declaration

    Swift

    public static func degrees(_ angle: Double) -> Double

    Parameters

    angle

    A double value, which specifies the angle in radians.

    Return Value

    A double value, which specifies the angle in degrees.

  • Converts the cartesian coordinate of the specified point to polar coordinates.

    Declaration

    Swift

    public static func cartesianToPolar(_ coordCenter: Point, point: Point, a: inout Double, r: inout Double)

    Parameters

    coordCenter

    The radius of thepoint.

    point

    The point in the cartesian coordinate system.

    a

    The angle of thepoint.

    coordCenter

    The radius of thepoint.

  • Converts the polar coordinate of the specifiedpoint to cartesian coordinates.

    Declaration

    Swift

    public static func polarToCartesian(_ coordCenter: Point, a: Double, r: Double, point: inout Point)

    Parameters

    coordCenter

    The radius of thepoint.

    a

    The angle of thepoint.

    coordCenter

    The radius of thepoint.

    point

    The point in the cartesian coordinate system.

  • Gets a Point from a Bezier curve.

    Declaration

    Swift

    public static func getBezierPoint(_ points: [Point], segment: Int, t: Double) -> Point

    Parameters

    points

    An array with points that define the controlpoints of the Bezier curve.

    segment

    The index of the segment on the Bezier curve, where the point is located.

    t

    A parameter of the Bezier curve, which ranges between 0 and 1.

    Return Value

    The Point at the specified Bezier curve with the given settings.

  • Measures the distance between a Point and a polyline.

    Declaration

    Swift

    public static func distanceToPolyline(_ point: Point, points: [Point]) -> Double

    Parameters

    point

    The point.

    points

    An array with Point objects, which define the polyline to which the distance is measured.

    Return Value

    The distance between the Point and the polyline.

  • Measures the distance between a Point and a line segment.

    Declaration

    Swift

    public static func distanceToLineSegment(_ point: Point, p1: Point, p2: Point) -> Double

    Parameters

    point

    The point.

    p1

    The start point of the line segment.

    p2

    The end point of the line segment.

    Return Value

    The distance between the Point and the line segment.

  • Returns the closest point that belongs to a given line to a given point.

    Declaration

    Swift

    public static func distancePoint(_ p: Point, a: Point, b: Point) -> Point

    Parameters

    p

    The point from which measuring starts.

    a

    The start point of the line.

    b

    The end point of the line.

    Return Value

    The closest to p point that lies on the ab line.

  • Finds the intersection point of two lines.

    Declaration

    Swift

    public static func lineIntersectNaN(_ m1: Point, m2: Point, n1: Point, n2: Point) -> Point

    Parameters

    m1

    The first point of the first line segment.

    m2

    The second point of the first segment.

    n1

    The first point of the second line segment.

    n2

    The second point of the second segment.

    Return Value

    The point where the two lines intersect. It can be with nan-coordinates if the two lines do not intersect.

  • Returns the shortest distance between the specified point and the given Bezier curve.

    Declaration

    Swift

    public static func distanceToBezier(_ point: Point, bezierPoints: [Point]) -> Double

    Parameters

    point

    The point.

    bezierPoints

    Array with control points that define the Bezier curve.

    Return Value

    The shortest distance between the point and the Bezier curve.

  • Calulates the shortest distance between a point and another point defined by its coordinates.

    Declaration

    Swift

    public static func distance(_ p: Point, x: Double, y: Double) -> Double

    Parameters

    p

    The point.

    x

    The x-coordinate of the second point.

    y

    The y-coordinate of the second point.

    Return Value

    The shortest distance between the points.

  • Calulates the shortest distance between a point and another point.

    Declaration

    Swift

    public static func distance(_ pt1: Point, pt2: Point) -> Double

    Parameters

    p1

    The first point.

    p2

    The second point.

    Return Value

    The shortest distance between the points.

  • Calulates the square of the shortest distance between a point and another point defined by its coordinates.

    Declaration

    Swift

    public static func distanceSquared(_ p: Point, x: Double, y: Double) -> Double

    Parameters

    p

    The point.

    x

    The x-coordinate of the second point.

    y

    The y-coordinate of the second point.

    Return Value

    The square of the shortest distance between the points.

  • Calulates the square of the shortest distance between a point and another point.

    Declaration

    Swift

    public static func distanceSquared(_ p1: Point, p2: Point) -> Double

    Parameters

    p1

    The first point.

    p2

    The second point.

    Return Value

    The square of the shortest distance between the points.

  • Normalizes the specified rectangle.

    Declaration

    Swift

    public static func normalizeRectangle(_ rect: Rect) -> Rect

    Parameters

    rect

    The rectangle to normalize.

    Return Value

    The normalized rectangle.

  • Calculates the coordinates of the specified point as a percent of the size of the bounding rectangle for a node.

    Declaration

    Swift

    public static func calculateRelativePercentPosition(_ nodeBounds: Rect, pos: Point) -> Point

    Parameters

    nodeBounds

    The bounding rectangle of the node.

    pos

    The point whose coordinates are calculated.

    Return Value

    The coordinates of the point as percents.