opensolid/geometry/1.2.0

NOTE: this package is not compatible with Elm 0.19.1

OpenSolid.Circle3d

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. Currently you can only do a few basic things with circles, such as measuring the area or circumference, but this should increase in the future.

Circles can be constructed by passing a record with centerPoint, axialDirection and radius fields to the Circle3d constructor, for example

exampleCircle =
    Circle3d
        { centerPoint = Point3d ( 2, 0, 1 )
        , axialDirection = Direction3d.z
        , radius = 3
        }

You must ensure the provided radius is positive (or zero, but that's not a very useful circle).

Accessors

centerPoint : Circle3d -> Point3d

Get the center point of a circle.

Circle3d.centerPoint exampleCircle
--> Point3d ( 2, 0, 1 )
axialDirection : Circle3d -> Direction3d

Get the axial direction of a circle.

Circle3d.axialDirection exampleCircle
--> Direction3d.z
radius : Circle3d -> Float

Get the radius of a circle.

Circle3d.radius exampleCircle
--> 3
diameter : Circle3d -> Float

Get the diameter of a circle.

Circl3d.diameter exampleCircle
--> 6
area : Circle3d -> Float

Get the area of a circle.

Circle3d.area exampleCircle
--> 28.2743
circumference : Circle3d -> Float

Get the circumference of a circle.

Circle3d.circumference exampleCircle
--> 18.8496

Transformations

scaleAbout : Point3d -> Float -> Circle3d -> Circle3d

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

Circle3d.scaleAbout Point3d.origin 3 exampleCircle
--> Circle3d
-->     { centerPoint = Point3d ( 6, 0, 3 )
-->     , axialDirection = Direction3d.z
-->     , radius = 9
-->     }
rotateAround : Axis3d -> Float -> Circle3d -> Circle3d

Rotate a circle around a given axis by a given angle (in radians).

Circle3d.rotateAround Axis3d.y (degrees 90) exampleCircle
--> Circle3d
-->     { centerPoint = Point3d ( 1, 0, -2 )
-->     , axialDirection = Direction3d.x
-->     , radius = 3
-->     }
translateBy : Vector3d -> Circle3d -> Circle3d

Translate a circle by a given displacement.

displacement =
    Vector3d ( 2, 1, 3 )


Circle3d.translateBy displacement exampleCircle
--> Circle3d
-->     { centerPoint = Point3d ( 4, 1, 4 )
-->     , axialDirection = Direction3d.z
-->     , radius = 3
-->     }
mirrorAcross : Plane3d -> Circle3d -> Circle3d

Mirror a circle across a given plane.

Circle3d.mirrorAcross Plane3d.xy exampleCircle
--> Circle3d
-->     { centerPoint = Point3d ( 2, 0, -1 )
-->     , axialDirection = Direction3d ( 0, 0, -1 )
-->     , radius = 3
-->     }

Coordinate frames

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.at (Point3d ( 1, 2, 3 ))


Circle3d.relativeTo localFrame exampleCircle
--> Circle3d
-->     { centerPoint = Point3d ( 1, -2, -2 )
-->     , axialDirection = Direction3d.z
-->     , radius = 3
-->     }
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.at (Point3d ( 1, 2, 3 ))


Circle3d.placeIn localFrame exampleCircle
--> Circle3d
-->     { centerPoint = Point3d ( 3, 2, 4 )
-->     , axialDirection = Direction3d.z
-->     , radius = 3
-->     }

Bounds

boundingBox : Circle3d -> BoundingBox3d

Get the minimal bounding box containing a given circle.

Circle3d.boundingBox exampleCircle
--> BoundingBox3d
-->     { minX = -1
-->     , maxX = 5
-->     , minY = -3
-->     , maxY = 3
-->     , minZ = 1
-->     , maxZ = 1
-->     }