ianmackenzie / elm-geometry / Circle3d

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:


type alias Circle3d units coordinates =
Geometry.Types.Circle3d units coordinates

Constructors

withRadius : Quantity Basics.Float units -> Direction3d coordinates -> Point3d units coordinates -> Circle3d units coordinates

Construct a circle from its radius, axial direction and center point:

exampleCircle =
    Circle3d.withRadius (Length.meters 3)
        Direction3d.z
        (Point3d.meters 2 0 1)

If you pass a negative radius, the absolute value will be used.

sweptAround : Axis3d units coordinates -> Point3d units coordinates -> Circle3d units coordinates

Construct a circle by sweeping the given point around the given axis.

Circle3d.sweptAround Axis3d.z (Point3d.meters 3 0 2)
--> Circle3d.withRadius (Length.meters 3)
-->     Direction3d.z
-->     (Point3d.meters 0 0 2)

on : SketchPlane3d units coordinates3d { defines : coordinates2d } -> Circle2d units coordinates2d -> Circle3d units coordinates3d

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 (Length.meters 3)
        (Point2d.meters 1 2)
--> Circle3d.withRadius (Length.meters 3)
-->     Direction3d.x
-->     (Point3d.meters 0 1 2)

throughPoints : Point3d units coordinates -> Point3d units coordinates -> Point3d units coordinates -> Maybe (Circle3d units coordinates)

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.meters 1 0 0)
    (Point3d.meters 0 1 0)
    (Point3d.meters 0 0 1)
--> Just <|
-->     Circle3d.withRadius (Length.meters 0.8165)
-->         (Direction3d.xyZ
-->             (Angle.degrees 45)
-->             (Angle.degrees 35.26)
-->         )
-->         (Point3d.meters 0.333 0.333 0.333)

Properties

centerPoint : Circle3d units coordinates -> Point3d units coordinates

Get the center point of a circle.

axialDirection : Circle3d units coordinates -> Direction3d coordinates

Get the axial direction of a circle.

radius : Circle3d units coordinates -> Quantity Basics.Float units

Get the radius of a circle.

diameter : Circle3d units coordinates -> Quantity Basics.Float units

Get the diameter of a circle (twice its radius).

axis : Circle3d units coordinates -> Axis3d units coordinates

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.

plane : Circle3d units coordinates -> Plane3d units coordinates

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.

area : Circle3d units coordinates -> Quantity Basics.Float (Quantity.Squared units)

Get the area of a circle.

circumference : Circle3d units coordinates -> Quantity Basics.Float units

Get the circumference (perimeter) of a circle.

boundingBox : Circle3d units coordinates -> BoundingBox3d units coordinates

Get the minimal bounding box containing a given circle.

Circle3d.boundingBox exampleCircle
--> BoundingBox3d.from
-->     (Point3d.meters -1 -3 1)
-->     (Point3d.meters 5 3 1)

Conversion

toArc : Circle3d units coordinates -> Arc3d units coordinates

Convert a circle to a 360 degree arc. The start point of the arc is unspecified.

Transformations

These transformations generally behave just like the ones in the Point3d module.

flip : Circle3d units coordinates -> Circle3d units coordinates

Flip the axial direction of a circle.

scaleAbout : Point3d units coordinates -> Basics.Float -> Circle3d units coordinates -> Circle3d units coordinates

Scale a circle around a given point by a given scale.

rotateAround : Axis3d units coordinates -> Angle -> Circle3d units coordinates -> Circle3d units coordinates

Rotate a circle around a given axis by a given angle.

translateBy : Vector3d units coordinates -> Circle3d units coordinates -> Circle3d units coordinates

Translate a circle by a given displacement.

translateIn : Direction3d coordinates -> Quantity Basics.Float units -> Circle3d units coordinates -> Circle3d units coordinates

Translate a circle in a given direction by a given distance.

mirrorAcross : Plane3d units coordinates -> Circle3d units coordinates -> Circle3d units coordinates

Mirror a circle across a given plane.

projectInto : SketchPlane3d units coordinates3d { defines : coordinates2d } -> Circle3d units coordinates3d -> Geometry.Types.Ellipse2d units coordinates2d

Project a circle into a sketch plane. Note that the result is in general an ellipse, not a circle!

inclinedCircle : Circle3d
inclinedCircle =
    Circle3d.withRadius (Length.meters 1)
        (Direction3d.xz (Angle.degrees 45))
        (Point3d.meters 1 2 3)

Circle3d.projectInto SketchPlane3d.xy inclinedCircle
--> Ellipse2d.with
-->     { centerPoint = Point2d.meters 1 2
-->     , xDirection = Direction2d.negativeY
-->     , xRadius = Length.meters 1
-->     , yRadius = Length.meters 0.7071
-->     }

The X radius of the returned ellipse will always be greater than or equal to the Y radius (the X axis will be the major axis and the Y axis will be the minor axis). Note that if the 3D circle is perfectly parallel to the sketch plane, then the resulting ellipse will be circular (its X and Y radii will be equal) and its X and Y axis directions will be chosen arbitrarily.

Unit conversions

at : Quantity Basics.Float (Quantity.Rate units2 units1) -> Circle3d units1 coordinates -> Circle3d units2 coordinates

Convert a circle from one units type to another, by providing a conversion factor given as a rate of change of destination units with respect to source units.

at_ : Quantity Basics.Float (Quantity.Rate units1 units2) -> Circle3d units1 coordinates -> Circle3d units2 coordinates

Convert a circle from one units type to another, by providing an 'inverse' conversion factor given as a rate of change of source units with respect to destination units.

Coordinate conversions

relativeTo : Frame3d units globalCoordinates { defines : localCoordinates } -> Circle3d units globalCoordinates -> Circle3d units localCoordinates

Take a circle defined in global coordinates, and return it expressed in local coordinates relative to a given reference frame.

placeIn : Frame3d units globalCoordinates { defines : localCoordinates } -> Circle3d units localCoordinates -> Circle3d units globalCoordinates

Take a circle considered to be defined in local coordinates relative to a given reference frame, and return that circle expressed in global coordinates.