CircleArc2

public struct CircleArc2<Vector> : GeometricType, CustomStringConvertible where Vector : Vector2Real
extension CircleArc2: LineIntersectableType
extension CircleArc2: Equatable where Vector: Equatable
extension CircleArc2: Hashable where Vector: Hashable

Represents a 2D arc of a circle as a center, radius, and start+sweep angles.

  • Declaration

    Swift

    public typealias Scalar = Vector.Scalar
  • The center of the arc’s circle.

    Declaration

    Swift

    public var center: Vector
  • The radius of the arc’s circle.

    Declaration

    Swift

    public var radius: Scalar
  • The starting angle of this arc, in radians.

    Declaration

    Swift

    public var startAngle: Angle<Scalar>
  • The sweep angle of this arc, in radians.

    Declaration

    Swift

    public var sweepAngle: Angle<Scalar>
  • Declaration

    Swift

    public var description: String { get }
  • Initializes a new circular arc with the given input parameters.

    Declaration

    Swift

    public init(
        center: Vector,
        radius: Scalar,
        startAngle: Scalar,
        sweepAngle: Scalar
    )
  • Initializes a new circular arc with the given input parameters.

    Declaration

    Swift

    public init(
        center: Vector,
        radius: Scalar,
        startAngle: Angle<Scalar>,
        sweepAngle: Angle<Scalar>
    )
  • Creates a new circular arc that fills the space between startPoint and endPoint, with a sweep angle of sweepAngle.

    Declaration

    Swift

    public init(
        startPoint: Vector,
        endPoint: Vector,
        sweepAngle: Angle<Scalar>
    )
  • Creates a new circular arc that fits the given start/end points on the circumference of the arc, and a center point.

    The sweep angle is chosen to be the shortest sweep angle that connects startAngle to endAngle.

    Note

    The initializer assumes that center is equally distant to both startPoint and endPoint.

    Declaration

    Swift

    public init(
        center: Vector,
        startPoint: Vector,
        endPoint: Vector
    )
  • Creates a new circular arc that fits the given start/end points on the circumference of the arc, and a center point.

    The sweep angle is chosen to be the clockwise sweep angle that connects startAngle to endAngle.

    Note

    The initializer assumes that center is equally distant to both startPoint and endPoint.

    Declaration

    Swift

    public init(
        clockwiseAngleToCenter center: Vector,
        startPoint: Vector,
        endPoint: Vector
    )
  • Constructs a circle with the same center + radius as this circle arc.

    Declaration

    Swift

    @inlinable
    var asCircle2: Circle2<Vector> { get }
  • Constructs an angle sweep from this arc’s start and sweep angles.

    Declaration

    Swift

    @inlinable
    var asAngleSweep: AngleSweep<Scalar> { get }
  • Returns the stop angle of this sweep, as the sum of startAngle + sweepAngle.

    Declaration

    Swift

    @inlinable
    var stopAngle: Angle<Scalar> { get }
  • Computes the area of this circular arc, when interpreted as a pie slice of a circle.

    Declaration

    Swift

    @inlinable
    var area: Scalar { get }
  • Computes the length of this circular arc.

    Declaration

    Swift

    @inlinable
    var arcLength: Scalar { get }
  • Computes the length of the chord represented by this circular arc.

    Declaration

    Swift

    @inlinable
    var chordLength: Scalar { get }
  • Returns the starting point on this arc.

    Declaration

    Swift

    @inlinable
    var startPoint: Vector { get }
  • Returns the end point on this arc.

    Declaration

    Swift

    @inlinable
    var endPoint: Vector { get }
  • Returns true if this circular arc contains a given angle in radians within its start + sweep region.

    Declaration

    Swift

    @_specialize(exported: true, kind: full, where Vector == Vector2<Double>)
    @_specialize(exported: true, kind: full, where Vector == Vector2<Float>)
    @inlinable
    func contains(_ angleInRadians: Scalar) -> Bool
  • Returns true if this circular arc contains a given angle value within its start + sweep region.

    Declaration

    Swift

    @_specialize(exported: true, kind: full, where Vector == Vector2<Double>)
    @_specialize(exported: true, kind: full, where Vector == Vector2<Float>)
    @inlinable
    func contains(_ angle: Angle<Scalar>) -> Bool
  • Clamps a given angle to be within this arc’s startAngle + sweepAngle range.

    Declaration

    Swift

    @inlinable
    func clamped(_ angle: Angle<Scalar>) -> Angle<Scalar>
  • Returns a point on the circle represented by this arc on a given angle.

    Declaration

    Swift

    @inlinable
    func pointOnAngle(_ angle: Angle<Scalar>) -> Vector
  • Returns the result of an intersection test between this circular arc and a given line.

    Declaration

    Swift

    func intersection<Line>(
        with line: Line
    ) -> PairLineIntersection<Vector> where Line: LineFloatingPoint, Vector == Line.Vector
  • Declaration

    Swift

    public func intersections<Line>(
        with line: Line
    ) -> LineIntersection<Vector> where Line: LineFloatingPoint, Vector == Line.Vector
  • Returns the minimal bounding box capable of fully containing this arc.

    Declaration

    Swift

    func bounds() -> AABB<Vector>
  • Returns the coordinates of the occupied quadrants that this arc sweeps through.

    The resulting array is up to four elements long, with each element representing an axis, from the arc’s center point, in the +/- x and +/- y direction, if the arc’s sweep includes that point.

    Declaration

    Swift

    func quadrants() -> [Vector]
  • Projects a given point to the closest point within this arc.

    Declaration

    Swift

    func project(_ point: Vector) -> Vector
  • Returns the squared distance to the closest point within this arc to the given point.

    Declaration

    Swift

    func distanceSquared(to point: Vector) -> Scalar