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:
Geometry.Types.Circle3d
withRadius : Basics.Float -> Direction3d -> Point3d -> Circle3d
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.
sweptAround : Axis3d -> Point3d -> Circle3d
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 ))
on : SketchPlane3d -> Circle2d -> Circle3d
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 ))
throughPoints : Point3d -> Point3d -> Point3d -> Maybe Circle3d
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 )
--> )
--> )
centerPoint : Circle3d -> Point3d
Get the center point of a circle.
Circle3d.centerPoint exampleCircle
--> Point3d.fromCoordinates ( 2, 0, 1 )
axialDirection : Circle3d -> Direction3d
Get the axial direction of a circle.
Circle3d.axialDirection exampleCircle
--> Direction3d.z
radius : Circle3d -> Basics.Float
Get the radius of a circle.
Circle3d.radius exampleCircle
--> 3
diameter : Circle3d -> Basics.Float
Get the diameter of a circle.
Circl3d.diameter exampleCircle
--> 6
axis : Circle3d -> Axis3d
Get 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 ))
plane : Circle3d -> Plane3d
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 ))
area : Circle3d -> Basics.Float
Get the area of a circle.
Circle3d.area exampleCircle
--> 28.2743
circumference : Circle3d -> Basics.Float
Get the circumference of a circle.
Circle3d.circumference exampleCircle
--> 18.8496
boundingBox : Circle3d -> BoundingBox3d
Get 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
--> }
scaleAbout : Point3d -> Basics.Float -> Circle3d -> Circle3d
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 ))
rotateAround : Axis3d -> Basics.Float -> Circle3d -> Circle3d
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 ))
translateBy : Vector3d -> Circle3d -> Circle3d
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 ))
translateIn : Direction3d -> Basics.Float -> Circle3d -> Circle3d
Translate a circle in a given direction by a given distance;
Circle3d.translateIn direction distance
is equivalent to
Circle3d.translateBy
(Vector3d.withLength distance direction)
mirrorAcross : Plane3d -> Circle3d -> Circle3d
Mirror a circle across a given plane.
Circle3d.mirrorAcross Plane3d.xy exampleCircle
--> Circle3d.withRadius 3
--> Direction3d.negativeZ
--> (Point3d.fromCoordinates ( 2, 0, -1 ))
projectInto : SketchPlane3d -> Circle3d -> Geometry.Types.Ellipse2d
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
--> }
relativeTo : Frame3d -> Circle3d -> Circle3d
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 ))
placeIn : Frame3d -> Circle3d -> Circle3d
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 ))