opensolid/geometry/2.0.1

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. This module contains functionality for:

  • Constructing circles around axes, on planes, or through points
  • Scaling, rotating and translating circles
  • Extracting circle properties like center point and area
type alias Circle3d =
Circle3d

Constructors

{ centerPoint : Point3d
, axialDirection : Direction3d
, radius : Float
}
-> Circle3d

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).

around : Axis3d -> Point3d -> Circle3d

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
-->     }
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.with
        { centerPoint =
            Point2d.fromCoordinates ( 1, 2 )
        , radius = 3
        }
--> Circle3d.with
-->     { centerPoint =
-->         Point3d.fromCoordinates ( 0, 1, 2 )
-->     , axialDirection = Direction3d.x
-->     , radius = 3
-->     }
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.with
-->         { centerPoint =
-->             Point3d.fromCoordinates
-->                 ( 0.333, 0.333, 0.333 )
-->         , axialDirection =
-->             Direction3d.with
-->                 { azimuth = degrees 45
-->                 , elevation = degrees 35.26
-->                 }
-->         , radius = 0.8165
-->         }
-->     )

Properties

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 -> Float

Get the radius of a circle.

Circle3d.radius exampleCircle
--> 3
diameter : Circle3d -> 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.with
-->     { originPoint =
-->         Point3d.fromCoordinates ( 2, 0, 1 )
-->     , direction = Direction3d.z
-->     }
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.with
-->     { originPoint =
-->         Point3d.fromCoordinates ( 2, 0, 1 )
-->     , normalDirection = Direction3d.z
-->     }
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
boundingBox : Circle3d -> BoundingBox3d

Get 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
-->     }

Transformations

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

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
-->     }
rotateAround : Axis3d -> Float -> Circle3d -> Circle3d

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
-->     }
translateBy : Vector3d -> Circle3d -> Circle3d

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
-->     }
mirrorAcross : Plane3d -> Circle3d -> Circle3d

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
-->     }

Coordinate conversions

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.with
-->     { centerPoint =
-->         Point3d.fromCoordinates ( 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.atPoint
        (Point3d.fromCoordinates ( 1, 2, 3 ))


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