diff --git a/geometry.go b/geometry.go index 3ac5543ac565a063e768afa1b3d9748ed5bcbb4e..e662c63ef93de95de7a690a21f703ac207010edc 100644 --- a/geometry.go +++ b/geometry.go @@ -34,11 +34,21 @@ import ( // x := u.Unit().Dot(v.Unit()) type Vec complex128 -// V returns a new 2d vector with the given coordinates. +// V returns a new 2D vector with the given coordinates. func V(x, y float64) Vec { return Vec(complex(x, y)) } +// X returns a 2D vector with coordinates (x, 0). +func X(x float64) Vec { + return V(x, 0) +} + +// Y returns a 2D vector with coordinates (0, y). +func Y(y float64) Vec { + return V(0, y) +} + // String returns the string representation of the vector u. // // u := pixel.V(4.5, -1.3)