add pixel.Unit

This commit is contained in:
faiface 2017-10-15 19:43:12 +02:00
parent 6215259c1d
commit 6e27fc84e7
1 changed files with 5 additions and 0 deletions

View File

@ -49,6 +49,11 @@ func V(x, y float64) Vec {
return Vec{x, y} return Vec{x, y}
} }
// Unit returns a vector of length 1 facing the given angle.
func Unit(angle float64) Vec {
return Vec{1, 0}.Rotated(angle)
}
// String returns the string representation of the vector u. // String returns the string representation of the vector u.
// //
// u := pixel.V(4.5, -1.3) // u := pixel.V(4.5, -1.3)