A Circle3d is defined by its center point, axial direction and radius. The
axial direction is the direction of the axis through the center of the circle
that all points on the circle are equidistant from, or equivalently the normal
direction of the plane defined by the circle. This module contains functionality
for:
Construct a circle from its radius, axial direction and center point:
exampleCircle =
Circle3d.withRadius 3
Direction3d.z
(Point3d.fromCoordinates ( 2, 0, 1 ))If you pass a negative radius, the absolute value will be used.
Construct a circle by sweeping the given point around the given axis.
Circle3d.sweptAround Axis3d.z
(Point3d.fromCoordinates ( 3, 0, 2 ))
--> Circle3d.withRadius 3
--> Direction3d.z
--> (Point3d.fromCoordinates ( 0, 0, 2 ))Construct a 3D circle lying on a sketch plane by providing a 2D circle specified in XY coordinates within the sketch plane.
Circle3d.on SketchPlane3d.yz <|
Circle2d.withRadius 3
(Point2d.fromCoordinates ( 1, 2 ))
--> Circle3d.withRadius 3
--> Direction3d.x
--> (Point3d.fromCoordinates ( 0, 1, 2 ))Attempt to construct a circle that passes through the three given points.
The axial direction of the returned circle will be such that the three points
are in counterclockwise order around it, according to the right-hand rule. If
the three given points are collinear, returns Nothing.
Circle3d.throughPoints
(Point3d.fromCoordinates ( 1, 0, 0 ))
(Point3d.fromCoordinates ( 0, 1, 0 ))
(Point3d.fromCoordinates ( 0, 0, 1 ))
--> Just
--> (Circle3d.withRadius 0.8165
--> (Direction3d.fromAzimuthAndElevation
--> (degrees 45)
--> (degrees 35.26)
--> )
--> (Point3d.fromCoordinates
--> ( 0.333, 0.333, 0.333 )
--> )
--> )Get the center point of a circle.
Circle3d.centerPoint exampleCircle
--> Point3d.fromCoordinates ( 2, 0, 1 )Get the axial direction of a circle.
Circle3d.axialDirection exampleCircle
--> Direction3d.zGet the radius of a circle.
Circle3d.radius exampleCircle
--> 3Get the diameter of a circle.
Circl3d.diameter exampleCircle
--> 6Get the central axis of a circle, perpendicular to its plane.
The origin point of the returned axis will be the center point of the circle.
Circle3d.axis exampleCircle
--> Axis3d.withDirection Direction3d.z
--> (Point3d.fromCoordinates ( 2, 0, 1 ))Get the plane that a circle lies in. The origin point of the returned plane will be the center point of the circle, and its normal direction will be the axial direction of the circle.
Circle3d.plane exampleCircle
--> Plane3d.withNormalDirection Direction3d.z
--> (Point3d.fromCoordinates ( 2, 0, 1 ))Get the area of a circle.
Circle3d.area exampleCircle
--> 28.2743Get the circumference of a circle.
Circle3d.circumference exampleCircle
--> 18.8496Get the minimal bounding box containing a given circle.
Circle3d.boundingBox exampleCircle
--> BoundingBox3d.fromExtrema
--> { minX = -1
--> , maxX = 5
--> , minY = -3
--> , maxY = 3
--> , minZ = 1
--> , maxZ = 1
--> }Scale a circle around a given point by a given scale.
Circle3d.scaleAbout Point3d.origin 3 exampleCircle
--> Circle3d.withRadius 3
--> Direction3d.z
--> (Point3d.fromCoordinates ( 6, 0, 3 ))Rotate a circle around a given axis by a given angle (in radians).
exampleCircle
|> Circle3d.rotateAround Axis3d.y (degrees 90)
--> Circle3d.withRadius 3
--> Direction3d.x
--> (Point3d.fromCoordinates ( 1, 0, -2 ))Translate a circle by a given displacement.
displacement =
Vector3d.fromComponents ( 2, 1, 3 )
Circle3d.translateBy displacement exampleCircle
--> Circle3d.withRadius 3
--> Direction3d.z
--> (Point3d.fromCoordinates ( 4, 1, 4 ))Translate a circle in a given direction by a given distance;
Circle3d.translateIn direction distanceis equivalent to
Circle3d.translateBy
(Vector3d.withLength distance direction)Mirror a circle across a given plane.
Circle3d.mirrorAcross Plane3d.xy exampleCircle
--> Circle3d.withRadius 3
--> Direction3d.negativeZ
--> (Point3d.fromCoordinates ( 2, 0, -1 ))Project a circle into a sketch plane.
inclinedCircle : Circle3d
inclinedCircle =
Circle3d.withRadius 1
(Direction3d.fromAzimuthAndElevation
(degrees 0)
(degrees 45)
)
(Point3d.fromCoordinates ( 1, 2, 3 ))
Circle3d.projectInto SketchPlane3d.xy inclinedCircle
--> Ellipse2d.with
--> { centerPoint =
--> Point2d.fromCoordinates ( 1, 2 )
--> , xDirection = Direction2d.negativeY
--> , xRadius = 1
--> , yRadius = 0.7071
--> }Take a circle 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 ))
Circle3d.relativeTo localFrame exampleCircle
--> Circle3d.withRadius 3
--> Direction3d.z
--> (Point3d.fromCoordinates ( 1, -2, -2 ))Take a circle considered to be defined in local coordinates relative to a given reference frame, and return that circle expressed in global coordinates.
localFrame =
Frame3d.atPoint
(Point3d.fromCoordinates ( 1, 2, 3 ))
Circle3d.placeIn localFrame exampleCircle
--> Circle3d.withRadius 3
--> Direction3d.z
--> (Point3d.fromCoordinates ( 3, 2, 4 ))