ianmackenzie / elm-geometry / VectorBoundingBox3d

A VectorBoundingBox3d is a version of a BoundingBox3d that contains vectors instead of points. All functions behave like their BoundingBox3d counterparts; see the BoundingBox3d docs and examples for details.


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

Constructors

singleton : Vector3d units coordinates -> VectorBoundingBox3d units coordinates

Construct a zero-width bounding box containing a single vector.

xyz : Quantity.Interval.Interval Basics.Float units -> Quantity.Interval.Interval Basics.Float units -> Quantity.Interval.Interval Basics.Float units -> VectorBoundingBox3d units coordinates

Construct a bounding box from separate X and Y intervals.

fromIntervals : ( Quantity.Interval.Interval Basics.Float units, Quantity.Interval.Interval Basics.Float units, Quantity.Interval.Interval Basics.Float units ) -> VectorBoundingBox3d units coordinates

Construct a bounding box from a tuple of X, Y and Z intervals.

from : Point3d units coordinates -> BoundingBox3d units coordinates -> VectorBoundingBox3d units coordinates

Given a point and a bounding box, compute the vector bounding box containing all possible vectors from that point to any point in the bounding box.

between : BoundingBox3d units coordinates -> BoundingBox3d units coordinates -> VectorBoundingBox3d units coordinates

Given two bounding boxes, compute the vector bounding box containing all possible vectors from a point in the first box to a point in the second box.

Hull

Functions for building bounding boxes containing several vectors.

hull2 : Vector3d units coordinates -> Vector3d units coordinates -> VectorBoundingBox3d units coordinates

Construct a bounding box containing the two vectors. The vectors can be given in any order and don't have to represent the 'primary' diagonal of the bounding box.

hull3 : Vector3d units coordinates -> Vector3d units coordinates -> Vector3d units coordinates -> VectorBoundingBox3d units coordinates

Build a bounding box that contains all three of the given vectors;

VectorBoundingBox3d.hull3 v1 v2 v3

is equivalent to

VectorBoundingBox3d.hull v1 [ v2, v3 ]

but is more efficient.

hull : Vector3d units coordinates -> List (Vector3d units coordinates) -> VectorBoundingBox3d units coordinates

Find the bounding box containing one or more input vectors:

VectorBoundingBox3d.hull v1 [ v2, v3, v4 ]

See also hullN.

hullN : List (Vector3d units coordinates) -> Maybe (VectorBoundingBox3d units coordinates)

Construct a bounding box containing all N vectors in the given list. If the list is empty, returns Nothing. If you know you have at least one point, you can use hull instead.

hullOf : (a -> Vector3d units coordinates) -> a -> List a -> VectorBoundingBox3d units coordinates

Like hull, but lets you work on any kind of item as long as a vector can be extracted from it.

hullOfN : (a -> Vector3d units coordinates) -> List a -> Maybe (VectorBoundingBox3d units coordinates)

Combination of hullOf and hullN.

Aggregation

Functions for combining several bounding boxes into one bounding box that contains all of the input boxes.

aggregate2 : VectorBoundingBox3d units coordinates -> VectorBoundingBox3d units coordinates -> VectorBoundingBox3d units coordinates

Build a bounding box that contains both given bounding boxes. (Note that this is not strictly speaking a 'union' in the precise mathematical sense.)

aggregate3 : VectorBoundingBox3d units coordinates -> VectorBoundingBox3d units coordinates -> VectorBoundingBox3d units coordinates -> VectorBoundingBox3d units coordinates

Build a bounding box that contains all three of the given bounding boxes;

VectorBoundingBox3d.aggregate3 b1 b2 b3

is equivalent to

VectorBoundingBox3d.aggregate b1 [ b2, b3 ]

but is more efficient.

aggregate : VectorBoundingBox3d units coordinates -> List (VectorBoundingBox3d units coordinates) -> VectorBoundingBox3d units coordinates

Find the bounding box containing one or more input boxes; works much like hull. See also aggregateN.

aggregateN : List (VectorBoundingBox3d units coordinates) -> Maybe (VectorBoundingBox3d units coordinates)

Construct a bounding box containing all bounding boxes in the given list. If the list is empty, returns Nothing. If you know you have at least one bounding box, you can use aggregate instead.

aggregateOf : (a -> VectorBoundingBox3d units coordinates) -> a -> List a -> VectorBoundingBox3d units coordinates

Like aggregate, but lets you work on any kind of item as long as a bounding box can be extracted from it.

aggregateOfN : (a -> VectorBoundingBox3d units coordinates) -> List a -> Maybe (VectorBoundingBox3d units coordinates)

Combination of aggregateOf and aggregateN.

Properties

xInterval : VectorBoundingBox3d units coordinates -> Quantity.Interval.Interval Basics.Float units

Get the range of X values contained by a bounding box.

yInterval : VectorBoundingBox3d units coordinates -> Quantity.Interval.Interval Basics.Float units

Get the range of Y values contained by a bounding box.

zInterval : VectorBoundingBox3d units coordinates -> Quantity.Interval.Interval Basics.Float units

Get the range of Z values contained by a bounding box.

intervals : VectorBoundingBox3d units coordinates -> ( Quantity.Interval.Interval Basics.Float units, Quantity.Interval.Interval Basics.Float units, Quantity.Interval.Interval Basics.Float units )

Convert a bounding box to a pair of X and Y intervals.

length : VectorBoundingBox3d units coordinates -> Quantity.Interval.Interval Basics.Float units

Get the range of lengths of vectors contained in a given bounding box.

Queries

contains : Vector3d units coordinates -> VectorBoundingBox3d units coordinates -> Basics.Bool

Check if a bounding box contains a particular point.

isContainedIn : VectorBoundingBox3d units coordinates -> VectorBoundingBox3d units coordinates -> Basics.Bool

Test if the second given bounding box is fully contained within the first (is a subset of it).

intersects : VectorBoundingBox3d units coordinates -> VectorBoundingBox3d units coordinates -> Basics.Bool

Test if two boxes touch or overlap at all (have any points in common);

VectorBoundingBox3d.intersects firstBox secondBox

is equivalent to

VectorBoundingBox3d.intersection firstBox secondBox
    /= Nothing

but is more efficient.

intersection : VectorBoundingBox3d units coordinates -> VectorBoundingBox3d units coordinates -> Maybe (VectorBoundingBox3d units coordinates)

Attempt to build a bounding box that contains all vectors common to both given bounding boxes. If the given boxes do not intersect, returns Nothing.

If two boxes just touch along an edge or at a corner, they are still considered to have an intersection, even though that intersection will have zero area (at least one of its dimensions will be zero).

Transformations

expandBy : Quantity Basics.Float units -> VectorBoundingBox3d units coordinates -> VectorBoundingBox3d units coordinates

Expand the given bounding box in all directions by the given offset. Negative offsets will be treated as positive (the absolute value will be used), so the resulting box will always be at least as large as the original.

Interpolation

interpolate : VectorBoundingBox3d units coordinates -> Basics.Float -> Basics.Float -> Basics.Float -> Vector3d units coordinates

Interpolate within a bounding box based on parameter values which range from 0 to 1.

Unit conversions

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

Convert a bounding box 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) -> VectorBoundingBox3d units1 coordinates -> VectorBoundingBox3d units2 coordinates

Convert a bounding box 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.

Arithmetic

multiplyBy : Basics.Float -> VectorBoundingBox3d units coordinates -> VectorBoundingBox3d units coordinates

Multiply (scale) a bounding box by the given value.

divideBy : Basics.Float -> VectorBoundingBox3d units coordinates -> VectorBoundingBox3d units coordinates

Divide a bounding box by the given value.

half : VectorBoundingBox3d units coordinates -> VectorBoundingBox3d units coordinates

Equivalent to multiplyBy 0.5 but shorter and slightly faster.

twice : VectorBoundingBox3d units coordinates -> VectorBoundingBox3d units coordinates

Equivalent to multiplyBy 2 but shorter and slightly faster.

plus : Vector3d units coordinates -> VectorBoundingBox3d units coordinates -> VectorBoundingBox3d units coordinates

Add a vector to a bounding box.

plusBoundingBox : VectorBoundingBox3d units coordinates -> VectorBoundingBox3d units coordinates -> VectorBoundingBox3d units coordinates

Add two bounding boxes together.

minus : Vector3d units coordinates -> VectorBoundingBox3d units coordinates -> VectorBoundingBox3d units coordinates

Subtract a vector from a bounding box. Note the argument order; to compute box - vector you would write

box |> VectorBoundingBox3d.minus vector

which is equivalent to

VectorBoundingBox3d.minus vector box

difference : Vector3d units coordinates -> VectorBoundingBox3d units coordinates -> VectorBoundingBox3d units coordinates

Subtract a bounding box from a vector (the opposite of minus). To compute vector - box you would write

VectorBoundingBox3d.difference vector box

minusBoundingBox : VectorBoundingBox3d units coordinates -> VectorBoundingBox3d units coordinates -> VectorBoundingBox3d units coordinates

Subtract one bounding box from another. Note the argument order; to compute firstBox - secondBox you would write

firstBox
    |> VectorBoundingBox3d.minusBoundingBox secondBox

which is equivalent to

VectorBoundingBox3d.minusBoundingBox secondBox firstBox

times : Quantity Basics.Float scalarUnits -> VectorBoundingBox3d vectorUnits coordinates -> VectorBoundingBox3d (Quantity.Product vectorUnits scalarUnits) coordinates

Multiply a vector bounding box by a scalar quantity, resulting in a vector bounding box with units Product vectorUnits scalarUnits. (To the compiler Product a b and Product b a are different unit types, so sometimes you will have to swap from product to times or vice versa to make the types work out.)

product : Quantity Basics.Float scalarUnits -> VectorBoundingBox3d vectorUnits coordinates -> VectorBoundingBox3d (Quantity.Product scalarUnits vectorUnits) coordinates

Multiply a scalar quantity and a vector bounding box, resulting in a vector bounding box with units Product scalarUnits vectorUnits.

timesUnitless : Quantity Basics.Float Quantity.Unitless -> VectorBoundingBox3d units coordinates -> VectorBoundingBox3d units coordinates

Multiply a vector bounding box by a unitless quantity, leaving the units unchanged.

timesInterval : Quantity.Interval.Interval Basics.Float scalarUnits -> VectorBoundingBox3d vectorUnits coordinates -> VectorBoundingBox3d (Quantity.Product vectorUnits scalarUnits) coordinates

Multiply a vector bounding box by an interval, resulting in a vector bounding box with units Product vectorUnits scalarUnits.

intervalProduct : Quantity.Interval.Interval Basics.Float scalarUnits -> VectorBoundingBox3d vectorUnits coordinates -> VectorBoundingBox3d (Quantity.Product scalarUnits vectorUnits) coordinates

Multiply an interval and a vector bounding box, resulting in a vector bounding box with units Product scalarUnits vectorUnits.

timesUnitlessInterval : Quantity.Interval.Interval Basics.Float Quantity.Unitless -> VectorBoundingBox3d units coordinates -> VectorBoundingBox3d units coordinates

Multiply a vector bounding box by a unitless interval, leaving the units unchanged.

Random vector generation

randomVector : VectorBoundingBox3d units coordinates -> Random.Generator (Vector3d units coordinates)

Create a random generator for vectors within a given bounding box.