Math.Geometry


Direction2D Module

Functions and values

Function or value Description

angleFrom d1 d2

Full Usage: angleFrom d1 d2

Parameters:
Returns: Angle

Find the counterclockwise angle from the first direction to the second. The result will be in the range -180 to 180 degrees

d1 : Direction2D<'Coordinates>
d2 : Direction2D<'Coordinates>
Returns: Angle

componentIn d2 d1

Full Usage: componentIn d2 d1

Parameters:
Returns: float

Find the component of one direction in another direction. This is equal to the cosine of the angle between the directions, or equivalently the dot product of the two directions converted to unit vectors. This is more general and flexible than using `xComponent` or `yComponent`, both of which can be expressed in terms of `componentIn`; for example, `Direction2d.xComponent direction` is equivalent to `Direction2d.componentIn Direction2d.x direction`.

d2 : Direction2D<'Coordinates>
d1 : Direction2D<'Coordinates>
Returns: float

components d

Full Usage: components d

Parameters:
Returns: float * float

Get the X and Y component of the direction in a tuple.

d : Direction2D<'Coordinates>
Returns: float * float

degrees d

Full Usage: degrees d

Parameters:
    d : float

Returns: Direction2D<'Coordinates>
d : float
Returns: Direction2D<'Coordinates>

equalWithin angle rhs lhs

Full Usage: equalWithin angle rhs lhs

Parameters:
Returns: bool

Compare two directions within an angular tolerance. Returns true if the absolute value of the angle between the two given directions is less than the given tolerance.

angle : Angle
rhs : Direction2D<'Coordinates>
lhs : Direction2D<'Coordinates>
Returns: bool

from first second

Full Usage: from first second

Parameters:
    first : Point2D<'Units, 'Coordinates>
    second : Point2D<'Units, 'Coordinates>

Returns: Direction2D<'Coordinates> option
first : Point2D<'Units, 'Coordinates>
second : Point2D<'Units, 'Coordinates>
Returns: Direction2D<'Coordinates> option

fromAngle angle

Full Usage: fromAngle angle

Parameters:
    angle : Angle

Returns: Direction2D<'Coordinates>
angle : Angle
Returns: Direction2D<'Coordinates>

fromComponents (x, y)

Full Usage: fromComponents (x, y)

Parameters:
    x : float
    y : float

Returns: Direction2D<'Coordinates> option
x : float
y : float
Returns: Direction2D<'Coordinates> option

mirrorAcross axis d

Full Usage: mirrorAcross axis d

Parameters:
Returns: Direction2D<'Coordinates>

Mirror a direction across a particular axis. Note that only the direction of the axis affects the result, since directions are position-independent.

axis : Axis2D<'Units, 'Corodiantes>
d : Direction2D<'Coordinates>
Returns: Direction2D<'Coordinates>

negativeX

Full Usage: negativeX

Returns: Direction2D<'Coordinates>
Returns: Direction2D<'Coordinates>

negativeY

Full Usage: negativeY

Returns: Direction2D<'Coordinates>
Returns: Direction2D<'Coordinates>

orthonormalize xVector xyVector

Full Usage: orthonormalize xVector xyVector

Parameters:
    xVector : Vector2D<'Units, 'Coordinates>
    xyVector : Vector2D<'Units, 'Coordinatres>

Returns: (Direction2D<'Coordinates> * Direction2D<'Coordinates>) option

Attempt to form a pair of perpendicular directions from the two given vectors by performing [Gram-Schmidt normalization](https://en.wikipedia.org/wiki/Gram%E2%80%93Schmidt_process): * The first returned direction will be equal to the direction of the first given vector * The second returned direction will be as close as possible to the second given vector while being perpendicular to the first returned direction

xVector : Vector2D<'Units, 'Coordinates>
xyVector : Vector2D<'Units, 'Coordinatres>
Returns: (Direction2D<'Coordinates> * Direction2D<'Coordinates>) option

perpendicularTo d

Full Usage: perpendicularTo d

Parameters:
Returns: Direction2D<'Coordaintes>

Construct a direction perpendicular to the given direction, by rotating the given direction 90 degrees counterclockwise. This is the same `Direction2D.rotateBy (Angle.degrees 90)` but is more efficient. Alias for `rotateCounterclockwise`.

d : Direction2D<'Coordaintes>
Returns: Direction2D<'Coordaintes>

placeIn reference direction

Full Usage: placeIn reference direction

Parameters:
    reference : Frame2D<'Units, 'GlobalCoordinates, 'LocalCoordinates>
    direction : Direction2D<'LocalCoordinates>

Returns: Direction2D<'GlobalCoordinates>

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

reference : Frame2D<'Units, 'GlobalCoordinates, 'LocalCoordinates>
direction : Direction2D<'LocalCoordinates>
Returns: Direction2D<'GlobalCoordinates>

positiveX

Full Usage: positiveX

Returns: Direction2D<'Coordinates>
Returns: Direction2D<'Coordinates>

positiveY

Full Usage: positiveY

Returns: Direction2D<'Coordinates>
Returns: Direction2D<'Coordinates>

radians r

Full Usage: radians r

Parameters:
    r : float

Returns: Direction2D<'Coordinates>
r : float
Returns: Direction2D<'Coordinates>

relativeTo frame d

Full Usage: relativeTo frame d

Parameters:
    frame : Frame2D<'Units, 'GlobalCoordaintes, 'LocalCoordinates>
    d : Direction2D<'GlobalCoordinates>

Returns: Direction2D<'LocalCoordaintes>

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

frame : Frame2D<'Units, 'GlobalCoordaintes, 'LocalCoordinates>
d : Direction2D<'GlobalCoordinates>
Returns: Direction2D<'LocalCoordaintes>

reverse direction

Full Usage: reverse direction

Parameters:
Returns: Direction2D<'Coordinates>
direction : Direction2D<'Coordinates>
Returns: Direction2D<'Coordinates>

rotateBy angle direction

Full Usage: rotateBy angle direction

Parameters:
Returns: Direction2D<'Coordinates>

Rotate a direction counterclockwise by a given angle.

angle : Angle
direction : Direction2D<'Coordinates>
Returns: Direction2D<'Coordinates>

rotateClockwise direction

Full Usage: rotateClockwise direction

Parameters:
Returns: Direction2D<'Coordinates>
direction : Direction2D<'Coordinates>
Returns: Direction2D<'Coordinates>

rotateCounterclockwise direction

Full Usage: rotateCounterclockwise direction

Parameters:
Returns: Direction2D<'Coordinates>
direction : Direction2D<'Coordinates>
Returns: Direction2D<'Coordinates>

toAngle d

Full Usage: toAngle d

Parameters:
Returns: Angle

Convert a direction to a polar angle (the counterclockwise angle from the positive X direction). The result will be in the range -180 to 180 degrees.

d : Direction2D<'Coordinates>
Returns: Angle

toTuple d

Full Usage: toTuple d

Parameters:
Returns: float * float

{-| Get the X and Y components of a direction as a tuple (X, Y).

d : Direction2D<'Coordinates>
Returns: float * float

toVector d

Full Usage: toVector d

Parameters:
Returns: Vector2D<Unitless, 'Coordinates>

Convert a direction to a unitless vector of length 1.

d : Direction2D<'Coordiantes>
Returns: Vector2D<Unitless, 'Coordinates>

x

Full Usage: x

Returns: Direction2D<'Coordinates>
Returns: Direction2D<'Coordinates>

xComponent d

Full Usage: xComponent d

Parameters:
Returns: float

Get the X component of the direction.

d : Direction2D<'Coordinates>
Returns: float

xy x y

Full Usage: xy x y

Parameters:
    x : float
    y : float

Returns: Direction2D<'Coordinates> option

Get a direction vector from the x and y components. This function takes care of normalizing the x and y components into the unit direction vector. This function also checks for the edge case where the x and y components are both zero. In that case, the function returns `None`.

x : float
y : float
Returns: Direction2D<'Coordinates> option

xyQuantity x y

Full Usage: xyQuantity x y

Parameters:
Returns: Direction2D<'Coordinates> option

Get a direction vector from the x and y length components. This function takes care of normalizing the x and y components into the unit direction vector. This function also checks for the edge case where the x and y components are both zero. In that case, the function returns `None`.

x : Quantity<'Units>
y : Quantity<'Units>
Returns: Direction2D<'Coordinates> option

xyUnsafe x y

Full Usage: xyUnsafe x y

Parameters:
    x : float
    y : float

Returns: Direction2D<'Coordinates>

Create a direction vector from the x and y components. This function doesn't perform either zero magnitude checks nor does it normalize the input vectors. This function should only be used with input constants or when you are sure that you aren't going to create a direction with an invalid state.

x : float
y : float
Returns: Direction2D<'Coordinates>

y

Full Usage: y

Returns: Direction2D<'Coordinates>
Returns: Direction2D<'Coordinates>

yComponent d

Full Usage: yComponent d

Parameters:
Returns: float

Get the Y component of the direction.

d : Direction2D<'Coordinates>
Returns: float