From a2b9bb5b5a225762620ce934a84b4c312e1a4871 Mon Sep 17 00:00:00 2001 From: faiface <faiface@ksp.sk> Date: Tue, 14 Mar 2017 13:27:18 +0100 Subject: [PATCH] add X and Y vector constructors --- geometry.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/geometry.go b/geometry.go index 3ac5543..e662c63 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) -- GitLab