DEPRECATED! Got moved to its separate package.
This module contains two ways of representing a point on a grid:
Position and Coord. Positions are meant to be stored, and coordinates are
meant to to calculations with.
moves a Point some amount of steps in a direction. This is the most used way how to change a position.
Apply Coordinates to a position to get the relative position.
move amount direction == add (fromDirection direction |> scaleby amount)Returns the difference between two positions.
difference p1 p2 == p1 <------- p2Coord is a non-comparable representation for 2D Coordinates.
Use this type for your calculations.
converts a Direction into a Vector with length 1.
converts any Vector into its nearest Direction value.
fromValue (0,0) == Right fromValue (1,1) == Down fromValue (-1,1) == Down fromValue (1,-1) == Up fromValue (-1,-1) == Up
Gets the distance between to points. (The length of the difference)
distance == vectorTo >> lengthScales Coordnates. Coordnates obtained by fromDirection have size 1.
fromDirection angle |> scaleBy l |> length == lReturns the length of the coordinate (distance to (0,0)
A
Positionis a comparable representation for 2D Coordinates.You should store your coordinates in this type.