opensolid/geometry/3.0.1

NOTE: this package is not compatible with Elm 0.19.1

Direction2d

Direction2d

A Direction2d represents a direction like 'up' or 'north' or 'forwards'. They are represented using X and Y components, and can be converted to vectors if necessary, but should be thought of as conceptually different. Directions have several uses, such as:

  • Constructing a vector from a length and direction
  • Determining the component of a vector in a particular direction (for example, finding the component of velocity in the up direction to get vertical speed)
  • Determining the (signed) angle between two directions
  • Defining the orientation of an axis or reference frame
type alias Direction2d =
Direction2d

Constants

x : Direction2d
y : Direction2d
positiveX : Direction2d
negativeX : Direction2d
positiveY : Direction2d
negativeY : Direction2d

Constructors

from : Point2d -> Point2d -> Maybe Direction2d
perpendicularTo : Direction2d -> Direction2d
orthonormalize : Vector2d -> Vector2d -> Maybe ( Direction2d, Direction2d )
orthogonalize : Direction2d -> Direction2d -> Maybe ( Direction2d, Direction2d )
unsafe : ( Float, Float ) -> Direction2d

Conversions

fromAngle : Float -> Direction2d
toAngle : Direction2d -> Float

Properties

components : Direction2d -> ( Float, Float )
xComponent : Direction2d -> Float
yComponent : Direction2d -> Float

Comparison

equalWithin : Float -> Direction2d -> Direction2d -> Bool

Measurement

componentIn : Direction2d -> Direction2d -> Float
angleFrom : Direction2d -> Direction2d -> Float

Conversion

toVector : Direction2d -> Vector2d

Transformations

reverse : Direction2d -> Direction2d
rotateClockwise : Direction2d -> Direction2d
rotateCounterclockwise : Direction2d -> Direction2d
rotateBy : Float -> Direction2d -> Direction2d
mirrorAcross : Axis2d -> Direction2d -> Direction2d

Coordinate conversions

relativeTo : Frame2d -> Direction2d -> Direction2d
placeIn : Frame2d -> Direction2d -> Direction2d