ianmackenzie/elm-geometry/1.0.0

NOTE: this package is not compatible with Elm 0.19.1

Frame2d

Frame2d

A Frame2d has an origin point and a pair of X and Y directions (which are always perpendicular to each other). It can be thought of as:

  • A local coordinate system: Most geometric types have associated relativeTo and placeIn functions that convert values of that type from global coordinates to local coordinates in a particular frame, and vice versa.
  • A pair of X and Y axes: It is often convenient to (for example) mirror across the X axis of a frame, or project onto its Y axis. Frames can also themselves be translated, rotated and mirrored!
  • A combined 2D position and orientation: For example, a Frame2d could be used to define the position and orientation of a spaceship in a 2D game. Movement of the ship would then be done by translating and rotating the frame.
type alias Frame2d =
Frame2d

Constants

xy : Frame2d

Constructors

atPoint : Point2d -> Frame2d
atCoordinates : ( Float, Float ) -> Frame2d
withXDirection : Direction2d -> Point2d -> Frame2d
withYDirection : Direction2d -> Point2d -> Frame2d
{ originPoint : Point2d
, xDirection : Direction2d
, yDirection : Direction2d
}
-> Frame2d

Properties

originPoint : Frame2d -> Point2d
xDirection : Frame2d -> Direction2d
yDirection : Frame2d -> Direction2d
isRightHanded : Frame2d -> Bool
xAxis : Frame2d -> Axis2d
yAxis : Frame2d -> Axis2d

Transformations

reverseX : Frame2d -> Frame2d
reverseY : Frame2d -> Frame2d
moveTo : Point2d -> Frame2d -> Frame2d
rotateBy : Float -> Frame2d -> Frame2d
rotateAround : Point2d -> Float -> Frame2d -> Frame2d
translateBy : Vector2d -> Frame2d -> Frame2d
translateIn : Direction2d -> Float -> Frame2d -> Frame2d
translateAlongOwn : (Frame2d -> Axis2d) -> Float -> Frame2d -> Frame2d
mirrorAcross : Axis2d -> Frame2d -> Frame2d

Coordinate conversions

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