ianmackenzie/elm-geometry/3.5.0

NOTE: the latest version is 4.0.0

Sphere3d

A Sphere3d is defined by its center point and radius. This module contains functionality for:

  • Constructing spheres through points
  • Scaling, rotating and translating spheres
  • Extracting sphere properties like center point and volume
type alias Sphere3d units coordinates =
Sphere3d units coordinates

Constructors

Point3d units coordinates
-> Quantity Float units
-> Sphere3d units coordinates

Construct a sphere from its center point and radius:

exampleSphere =
    Sphere3d.atPoint (Point3d.meters 1 2 1)
        (Length.meters 3)

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

Quantity Float units
-> Point3d units coordinates
-> Sphere3d units coordinates

Construct a sphere from its radius and center point. Flipped version of atPoint that may be more useful in some situations like constructing a bunch of spheres of the same radius at different points:

spheres =
    List.map (Sphere3d.withRadius radius) listOfPoints
atOrigin : Quantity Float units -> Sphere3d units coordinates

Construct a sphere at the origin with the given radius.

Point3d units coordinates
-> Point3d units coordinates
-> Point3d units coordinates
-> Point3d units coordinates
-> Maybe (Sphere3d units coordinates)

Attempt to construct a sphere that passes through the four given points. Returns Nothing if four given points are coplanar.

Sphere3d.throughPoints
    (Point3d.meters 1 0 0)
    (Point3d.meters -1 0 0)
    (Point3d.meters 0 1 0)
    (Point3d.meters 0 0 0.5)
--> Just <|
-->     Sphere3d.withRadius (Length.meters 1.25)
-->         (Point3d.meters 0 0 -0.75)


-- Four coplanar points (in the XY plane)
Sphere3d.throughPoints
    (Point3d.meters 1 0 0)
    (Point3d.meters -1 0 0)
    (Point3d.meters 0 1 0)
    (Point3d.meters 0 -1 0)
--> Nothing

Properties

centerPoint : Sphere3d units coordinates -> Point3d units coordinates

Get the center point of a sphere.

radius : Sphere3d units coordinates -> Quantity Float units

Get the radius of a sphere.

diameter : Sphere3d units coordinates -> Quantity Float units

Get the diameter of a sphere (twice the radius).

volume : Sphere3d units coordinates -> Quantity Float (Cubed units)

Get the volume of a sphere.

surfaceArea : Sphere3d units coordinates -> Quantity Float (Squared units)

Get the surface area of a sphere.

circumference : Sphere3d units coordinates -> Quantity Float units

Get the circumference of a sphere (the circumference of a great circle of the sphere).

boundingBox : Sphere3d units coordinates -> BoundingBox3d units coordinates

Get the minimal bounding box containing a given sphere.

Sphere3d.boundingBox exampleSphere
--> BoundingBox3d.from
-->     (Point3d.meters -2 -1 -2)
-->     (Point3d.meters 4 5 4)

Queries

contains : Point3d units coordinates -> Sphere3d units coordinates -> Bool

Check if a sphere contains a given point.

Transformations

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

Point3d units coordinates
-> Float
-> Sphere3d units coordinates
-> Sphere3d units coordinates

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

Axis3d units coordinates
-> Angle
-> Sphere3d units coordinates
-> Sphere3d units coordinates

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

Vector3d units coordinates
-> Sphere3d units coordinates
-> Sphere3d units coordinates

Translate a sphere by a given displacement.

Direction3d coordinates
-> Quantity Float units
-> Sphere3d units coordinates
-> Sphere3d units coordinates

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

Plane3d units coordinates
-> Sphere3d units coordinates
-> Sphere3d units coordinates

Mirror a sphere across a given plane.

Plane3d units coordinates
-> Sphere3d units coordinates
-> Circle3d units coordinates

Find the orthographic projection of a sphere onto a plane.

Sphere3d.projectOnto Plane3d.xy exampleSphere
--> Circle3d.withRadius (Length.meters 3)
-->     Direction3d.z
-->     (Point3d.meters 1 2 0)
SketchPlane3d units coordinates3d { defines : coordinates2d }
-> Sphere3d units coordinates3d
-> Circle2d units coordinates2d

Find the orthographic projection of a sphere into a sketch plane.

Sphere3d.projectInto SketchPlane3d.xy exampleSphere
--> Circle2d.withRadius (Length.meters 3)
-->     (Point2d.meters 1 2)

Unit conversions

at :
Quantity Float (Rate units2 units1)
-> Sphere3d units1 coordinates
-> Sphere3d units2 coordinates

Convert a sphere 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 Float (Rate units1 units2)
-> Sphere3d units1 coordinates
-> Sphere3d units2 coordinates

Convert a sphere 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

Frame3d units globalCoordinates { defines : localCoordinates }
-> Sphere3d units globalCoordinates
-> Sphere3d units localCoordinates

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

Frame3d units globalCoordinates { defines : localCoordinates }
-> Sphere3d units localCoordinates
-> Sphere3d units globalCoordinates

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