ianmackenzie / elm-geometry / Rectangle3d

The Rectangle3d type is an extension of Rectangle2d that exists in 3D. In most cases it will be most convenient to create a Rectangle3d by creating a Rectangle2d on a particular SketchPlane3d, using Rectangle3d.on. This module then contains functionality for:


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

Construction

on : SketchPlane3d units coordinates3d { defines : coordinates2d } -> Rectangle2d units coordinates2d -> Rectangle3d units coordinates3d

Construct a 3D rectangle lying on a sketch plane by providing a 2D rectangle specified in XY coordinates within the sketch plane. For example, to create a 3D rectangle lying on the YZ plane:

rectangle =
    Rectangle3d.on SketchPlane3d.yz <|
        Rectangle2d.from
            (Point2d.meters 1 2)
            (Point2d.meters 3 4)

Rectangle3d.vertices rectangle
--> [ Point3d.meters 0 1 2
--> , Point3d.meters 0 3 2
--> , Point3d.meters 0 3 4
--> , Point3d.meters 0 1 4
--> ]

centeredOn : SketchPlane3d units coordinates defines -> ( Quantity Basics.Float units, Quantity Basics.Float units ) -> Rectangle3d units coordinates

Construct a rectangle centered on the axes of the given sketch plane, with the given overall dimensions.

Properties

dimensions : Rectangle3d units coordinates -> ( Quantity Basics.Float units, Quantity Basics.Float units )

Get the overall dimensions (width and height) of a rectangle.

axes : Rectangle3d units coordinates -> SketchPlane3d units coordinates defines

Get the central axes of a rectangle as a SketchPlane3d. The origin point of the sketch plane will be the center point of the rectangle.

xAxis : Rectangle3d units coordinates -> Axis3d units coordinates

Get the X axis of a rectangle.

yAxis : Rectangle3d units coordinates -> Axis3d units coordinates

Get the Y axis of a rectangle.

centerPoint : Rectangle3d units coordinates -> Point3d units coordinates

Get the center point of a rectangle.

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

Get the area of a rectangle.

vertices : Rectangle3d units coordinates -> List (Point3d units coordinates)

Get the vertices of a rectangle as a list. The vertices will be returned in counterclockwise order with respect to the SketchPlane3d defining the rectangle's axes.

edges : Rectangle3d units coordinates -> List (LineSegment3d units coordinates)

Get the edges of a rectangle as a list. The edges will be returned in counterclockwise order with respect to the SketchPlane3d defining the rectangle's axes.

boundingBox : Rectangle3d units coordinates -> BoundingBox3d units coordinates

Get the minimal bounding box containing a given rectangle.

Interpolation

interpolate : Rectangle3d units coordinates -> Basics.Float -> Basics.Float -> Point3d units coordinates

Interpolate within a rectangle based on coordinates which range from 0 to 1. For example, the four vertices of a given rectangle are

[ Rectangle3d.interpolate rectangle 0 0
, Rectangle3d.interpolate rectangle 1 0
, Rectangle3d.interpolate rectangle 1 1
, Rectangle3d.interpolate rectangle 0 1
]

and its center point is

Rectangle3d.interpolate rectangle 0.5 0.5

Transformation

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

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

Scale a rectangle about a given point by a given scale. Note that scaling by a negative value will flip the directions of the rectangle's axes.

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

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

translateBy : Vector3d units coordinates -> Rectangle3d units coordinates -> Rectangle3d units coordinates

Translate a rectangle by a given displacement.

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

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

mirrorAcross : Plane3d units coordinates -> Rectangle3d units coordinates -> Rectangle3d units coordinates

Mirror a rectangle across a given plane.

Unit conversions

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

Convert a rectangle 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) -> Rectangle3d units1 coordinates -> Rectangle3d units2 coordinates

Convert a rectangle 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 } -> Rectangle3d units globalCoordinates -> Rectangle3d units localCoordinates

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

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

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

Random point generation

randomPoint : Rectangle3d units coordinates -> Random.Generator (Point3d units coordinates)

Create a random generator for points within a given rectangle.