An Arc3d is a section of a circle in 3D, defined by its central axis,
start point and swept angle (the counterclockwise angle around the axis from the
start point to the arc's end point). This module includes functionality for
Construct an arc around the given axis, with the given start point and swept angle:
exampleArc =
Arc3d.around Axis3d.z
{ startPoint =
Point3d.fromCoordinates ( 1, 1, 0 )
, sweptAngle = degrees 90
}
Arc3d.centerPoint exampleArc
--> Point3d.origin
Arc3d.endPoint exampleArc
--> Point3d.fromCoordinates ( -1, 1, 0 )Positive swept angles result in a counterclockwise (right-handed) rotation around the given axis and vice versa for negative swept angles. The center point of the returned arc will lie on the given axis.
Construct a 3D arc lying on a sketch plane by providing a 2D arc specified in XY coordinates within the sketch plane.
arc =
Arc3d.on SketchPlane3d.xz <|
Arc2d.with
{ centerPoint =
Point2d.fromCoordinates ( 1, 1 )
, startPoint =
Point2d.fromCoordinates ( 3, 1 )
, sweptAngle = degrees 90
}
Arc3d.centerPoint arc
--> Point3d.fromCoordinates ( 1, 0, 1 )
Arc3d.radius arc
--> 2
Arc3d.startPoint arc
--> Point3d.fromCoordinates ( 3, 0, 1 )
Arc3d.endPoint arc
--> Point3d.fromCoordinates ( 1, 0, 3 )Attempt to construct an arc that starts at the first given point, passes
through the second given point and ends at the third given point. If the three
points are collinear, returns Nothing.
p1 =
Point3d.fromCoordinates ( 0, 0, 1 )
p2 =
Point3d.origin
p3 =
Point3d.fromCoordinates ( 0, 1, 0 )
Arc3d.throughPoints ( p1, p2, p3 )
--> Just
--> (Arc3d.on SketchPlane3d.yz <|
--> Arc2d.with
--> { centerPoint =
--> Point2d.fromCoordinates
--> ( 0.5, 0.5 )
--> , startPoint =
--> Point3d.fromCoordinates ( 0, 1 )
--> , sweptAngle = degrees 180
--> }
--> )Get the axial direction of an arc.
Arc3d.axialDirection exampleArc
--> Direction3d.zGet the central axis of an arc. The origin point of the axis will be equal to the center point of the arc.
Arc3d.axis exampleArc
--> Axis3d.zGet the center point of an arc.
Arc3d.centerPoint exampleArc
--> Point3d.originGet the radius of an arc.
Arc3d.radius exampleArc
--> 1.4142Get the start point of an arc.
Arc3d.startPoint exampleArc
--> Point3d.fromCoordinates ( 1, 1, 0 )Get the end point of an arc.
Arc3d.endPoint exampleArc
--> Point3d.fromCoordinates ( -1, 1, 0 )Get the swept angle of an arc in radians.
Arc3d.sweptAngle exampleArc
--> 1.5708A positive swept angle means that the arc is formed by rotating the given start point counterclockwise around the central axis, and vice versa for a negative angle.
Get the point along an arc at a given parameter value. A parameter value of 0 corresponds to the start point of the arc and a value of 1 corresponds to the end point.
Arc3d.pointOn exampleArc 0.5
--> Point3d.fromCoordinates ( 0, 1.4142, 0 )Get the derivative of an arc with respect to a parameter that is 0 at the start point of the arc and 1 at the end point of the arc.
Arc3d.derivative exampleArc 0
--> Vector3d.fromComponents ( -1.5708, 1.5708, 0 )
Arc3d.derivative exampleArc 1
--> Vector3d.fromComponents ( -1.5708, -1.5708, 0 )Evaluate an arc at a given parameter value, returning the point on the arc at that parameter value and the derivative with respect to that parameter value.
Arc3d.evaluate exampleArc 0
--> ( Point3d.fromCoordinates ( 1, 1, 0 )
--> , Vector3d.fromComponents ( -1.5708, 1.5708, 0 )
--> )
Arc3d.evaluate exampleArc 0.5
--> ( Point3d.fromCoordinates ( 1.4142, 0, 0 )
--> , Vector3d.fromComponents ( -2.2214, 0, 0 )
--> )
Arc3d.evaluate exampleArc 1
--> ( Point3d.fromCoordinates ( -1, 1, 0 )
--> , Vector3d.fromComponents ( -1.5708, -1.5708, 0 )
--> )Equivalent to (but more efficient than) calling pointOn and derivative
separately.
Approximate an arc as a polyline, within the specified tolerance.
Arc3d.toPolyline 0.1 exampleArc
--> Polyline3d.fromVertices
--> [ Point3d.fromCoordinates ( 1, 1, 0 )
--> , Point3d.fromCoordinates ( 0.366, 1.366, 0 )
--> , Point3d.fromCoordinates ( -0.366, 1.366, 0 )
--> , Point3d.fromCoordinates ( -1, 1, 0 )
--> ]A tolerance of zero will be treated as infinity (a single line segment will be returned).
Reverse the direction of an arc, so that the start point becomes the end point and vice versa. The resulting arc will have the same axis as the original but a swept angle with the opposite sign.
Arc3d.reverse exampleArc
--> Arc3d.around Axis3d.z
--> { startPoint =
--> Point3d.fromCoordinates ( -1, 1, 0 )
--> , sweptAngle = degrees -90
--> }Scale an arc about the given center point by the given scale.
point =
Point3d.fromCoordinates ( 0, -1, 0 )
Arc3d.scaleAbout point 2 exampleArc
--> Arc3d.around
--> (Axis3d.with
--> { originPoint =
--> Point3d.fromCoordinates ( 0, 1, 0 )
--> , direction = Direction3d.z
--> }
--> )
--> { startPoint =
--> Point3d.fromCoordinates ( 2, 3, 0 )
--> , sweptAngle = degrees 90
--> }Rotate an arc around a given axis by a given angle (in radians).
Arc3d.rotateAround Axis3d.x (degrees 90) exampleArc
--> Arc3d.around (Axis3d.flip Axis3d.y)
--> { startPoint =
--> Point3d.fromCoordinates ( 1, 0, 1 )
--> , sweptAngle = degrees 90
--> }Translate an arc by a given displacement.
displacement =
Vector3d.fromComponents ( 2, 1, 3 )
Arc3d.translateBy displacement exampleArc
--> Arc3d.around
--> (Axis3d.with
--> { originPoint = Point3d ( 2, 1, 3 )
--> , direction = Direction3d.z
--> }
--> )
--> { startPoint =
--> Point3d.fromCoordinates ( 3, 2, 3 )
--> , sweptAngle = degrees 90
--> }Mirror an arc across a given plane.
Arc3d.mirrorAcross Plane3d.xy exampleArc
--> Arc3d.around (Axis3d.flip Axis3d.z)
--> { startPoint =
--> Point3d.fromCoordinates ( 1, 1, 0 )
--> , sweptAngle = degrees -90
--> }Note that this flips the sign of the arc's swept angle.
Project an arc into a sketch plane.
axis : Axis3d
axis =
Axis3d.with
{ originPoint =
Point3d.fromCoordinates ( 1, 2, 3 )
, direction =
Direction3d.with
{ azimuth = 0
, elevation = degrees 45
}
}
arc : Arc3d
arc =
Arc3d.around axis
{ startPoint =
Point3d.fromCoordinates ( 1, 4, 3 )
, sweptAngle = degrees 45
}
Arc3d.projectInto SketchPlane3d.xy arc
--> EllipticalArc2d.with
--> { centerPoint =
--> Point2d.fromCoordinates ( 1, 2 )
--> , xDirection = Direction2d.y
--> , xRadius = 2
--> , yRadius = 1.4142
--> , startAngle = degrees 0
--> , sweptAngle = degrees 45
--> }Take an arc defined in global coordinates, and return it expressed in local coordinates relative to a given reference frame.
localFrame =
Frame3d.atPoint
(Point3d.fromCoordinates ( 1, 2, 3 ))
Arc3d.relativeTo localFrame exampleArc
--> Arc3d.around
--> (Axis3d.with
--> { originPoint = Point3d ( -1, -2, -3 )
--> , direction = Direction3d.z
--> }
--> )
--> { startPoint =
--> Point3d.fromCoordinates ( 0, -1, -3 )
--> , sweptAngle = degrees 90
--> }Take an arc considered to be defined in local coordinates relative to a given reference frame, and return that arc expressed in global coordinates.
localFrame =
Frame3d.atPoint
(Point3d.fromCoordinates ( 1, 2, 3 ))
Arc3d.placeIn localFrame exampleArc
--> Arc3d.around
--> (Axis3d.with
--> { originPoint =
--> Point3d.fromCoordinates ( 1, 2, 3 )
--> , direction = Direction3d.z
--> }
--> )
--> { startPoint =
--> Point3d.fromCoordinates ( 2, 3, 3 )
--> , sweptAngle = degrees 90
--> }