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 center point, axial direction and radius:
exampleCircle =
Circle3d.with
{ centerPoint =
Point3d.fromCoordinates ( 2, 0, 1 )
, axialDirection = Direction3d.z
, radius = 3
}The actual radius of the circle will be the absolute value of the given radius
(passing radius = -2 will have the same effect as radius = 2).
Construct a circle around the given axis that passes through the given point.
point =
Point3d.fromCoordinates ( 3, 0, 2 )
Circle3d.around Axis3d.z point
--> Circle3d.with
--> { centerPoint =
--> Point3d.fromCoordinates ( 0, 0, 2 )
--> , axialDirection = Direction3d.z
--> , radius = 3
--> }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.with
{ centerPoint =
Point2d.fromCoordinates ( 1, 2 )
, radius = 3
}
--> Circle3d.with
--> { centerPoint =
--> Point3d.fromCoordinates ( 0, 1, 2 )
--> , axialDirection = Direction3d.x
--> , radius = 3
--> }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.with
--> { centerPoint =
--> Point3d.fromCoordinates
--> ( 0.333, 0.333, 0.333 )
--> , axialDirection =
--> Direction3d.with
--> { azimuth = degrees 45
--> , elevation = degrees 35.26
--> }
--> , radius = 0.8165
--> }
--> )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.with
--> { originPoint =
--> Point3d.fromCoordinates ( 2, 0, 1 )
--> , direction = Direction3d.z
--> }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.with
--> { originPoint =
--> Point3d.fromCoordinates ( 2, 0, 1 )
--> , normalDirection = Direction3d.z
--> }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.with
--> { 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.with
--> { centerPoint =
--> Point3d.fromCoordinates ( 6, 0, 3 )
--> , axialDirection = Direction3d.z
--> , radius = 9
--> }Rotate a circle around a given axis by a given angle (in radians).
exampleCircle
|> Circle3d.rotateAround Axis3d.y (degrees 90)
--> Circle3d.with
--> { centerPoint =
--> Point3d.fromCoordinates ( 1, 0, -2 )
--> , axialDirection = Direction3d.x
--> , radius = 3
--> }Translate a circle by a given displacement.
displacement =
Vector3d.fromComponents ( 2, 1, 3 )
Circle3d.translateBy displacement exampleCircle
--> Circle3d.with
--> { centerPoint =
--> Point3d.fromCoordinates ( 4, 1, 4 )
--> , axialDirection = Direction3d.z
--> , radius = 3
--> }Mirror a circle across a given plane.
Circle3d.mirrorAcross Plane3d.xy exampleCircle
--> Circle3d.with
--> { centerPoint =
--> Point3d.fromCoordinates ( 2, 0, -1 )
--> , axialDirection = Direction3d.negativeZ
--> , radius = 3
--> }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.with
--> { centerPoint =
--> Point3d.fromCoordinates ( 1, -2, -2 )
--> , axialDirection = Direction3d.z
--> , radius = 3
--> }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.with
--> { centerPoint =
--> Point3d.fromCoordinates ( 3, 2, 4 )
--> , axialDirection = Direction3d.z
--> , radius = 3
--> }