ianmackenzie/elm-geometry/4.0.0

Cylinder3d

A Cylinder3d consists of a cylindrical outer surface and two circular end caps; it is defined by its center point, axial direction, radius and overall length. This module contains functionality for:

  • Constructing cylinders in various ways
  • Scaling, rotating and translating cylinders
  • Extracting cylinder properties like center point and volume
type alias Cylinder3d units coordinates =
Cylinder3d units coordinates

Constructors

Axis3d units coordinates
-> { start : Quantity Float units
, end : Quantity Float units
, radius : Quantity Float units
}
-> Cylinder3d units coordinates

Construct a cylinder that lies along the given axis, with the start and end points given as (signed) distances along that axis:

exampleCylinder =
    Cylinder3d.along Axis3d.x
        { start = Length.meters -1
        , end = Length.meters 3
        , radius = Length.meters 1
        }


Cylinder3d.startPoint exampleCylinder
--> Point3d.meters -1 0 0


Cylinder3d.endPoint exampleCylinder
--> Point3d.meters 3 0 0


Cylinder3d.length exampleCylinder
--> Length.meters 4

Note that end may be less than start, but then the axial direction of the returned cylinder will be the opposite of the axial direction of the given axis.

Point3d units coordinates
-> Direction3d coordinates
-> { radius : Quantity Float units
, length : Quantity Float units
}
-> Cylinder3d units coordinates

Construct a cylinder given its center point, axial direction, radius and length. Negative values for radius or length will be treated as positive (the absolute values will be used).

Point3d units coordinates
-> Direction3d coordinates
-> { radius : Quantity Float units
, length : Quantity Float units
}
-> Cylinder3d units coordinates

Construct a cylinder given its start point, axial direction, radius and length. Negative values for radius or length will be treated as positive (the absolute values will be used).

Point3d units coordinates
-> Point3d units coordinates
-> Quantity Float units
-> Maybe (Cylinder3d units coordinates)

Attempt to construct a cylinder from the given start point, end point and radius. If the start and end points are coincident (the same point), returns Nothing.

Properties

axis : Cylinder3d units coordinates -> Axis3d units coordinates

Get the central axis of a cylinder. The origin point of the axis will be at the center point of the cylinder, and the direction of the axis will be from the cylinder's start point towards its end point.

centerPoint : Cylinder3d units coordinates -> Point3d units coordinates

Get the center point of a cylinder.

axialDirection : Cylinder3d units coordinates -> Direction3d coordinates

Get the axial direction of a cylinder.

radius : Cylinder3d units coordinates -> Quantity Float units

Get the radius of a cylinder.

diameter : Cylinder3d units coordinates -> Quantity Float units

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

length : Cylinder3d units coordinates -> Quantity Float units

Get the overall length of a cylinder.

startPoint : Cylinder3d units coordinates -> Point3d units coordinates

Get the start point of a cylinder. This is the center point of the circle that forms the start cap of the cylinder.

endPoint : Cylinder3d units coordinates -> Point3d units coordinates

Get the end point of a cylinder. This is the center point of the circle that forms the end cap of the cylinder.

startCap : Cylinder3d units coordinates -> Circle3d units coordinates

Get the circle at the start of a cylinder. The axial direction of this circle will be the reverse of the axial direction of the cylinder itself (the circle axial direction will point backwards/outwards).

endCap : Cylinder3d units coordinates -> Circle3d units coordinates

Get the circle at the end of a cylinder. The axial direction of this circle will be the same as that of the cylinder itself.

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

Get the volume of a cylinder.

boundingBox : Cylinder3d units coordinates -> BoundingBox3d units coordinates

Get the minimal bounding box containing a given cylinder.

Queries

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

Check if a cylinder contains a given point.

Transformations

reverse : Cylinder3d units coordinates -> Cylinder3d units coordinates

Reverse a cylinder so that the start point becomes the end point and vice versa. This also means that the axial direction will be reversed.

The remaining transformations generally behave just like the ones in the Point3d module.

Point3d units coordinates
-> Float
-> Cylinder3d units coordinates
-> Cylinder3d units coordinates

Scale a cylinder about a given point by a given scale.

Axis3d units coordinates
-> Angle
-> Cylinder3d units coordinates
-> Cylinder3d units coordinates

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

Vector3d units coordinates
-> Cylinder3d units coordinates
-> Cylinder3d units coordinates

Translate a cylinder by a given displacement.

Direction3d coordinates
-> Quantity Float units
-> Cylinder3d units coordinates
-> Cylinder3d units coordinates

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

Plane3d units coordinates
-> Cylinder3d units coordinates
-> Cylinder3d units coordinates

Mirror a cylinder across a given plane.

Unit conversions

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

Convert a cylinder 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)
-> Cylinder3d units1 coordinates
-> Cylinder3d units2 coordinates

Convert a cylinder 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 }
-> Cylinder3d units localCoordinates
-> Cylinder3d units globalCoordinates

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

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

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