add Vec.XY method

This commit is contained in:
faiface 2016-12-01 01:01:36 +01:00
parent 3b70c803c2
commit 7023d5dfdc
1 changed files with 5 additions and 0 deletions

5
vec.go
View File

@ -56,6 +56,11 @@ func (u Vec) Y() float64 {
return imag(u)
}
// XY returns the components of a vector in two return values.
func (u Vec) XY() (x, y float64) {
return real(u), imag(u)
}
// Len returns the length of a vector u.
func (u Vec) Len() float64 {
return cmplx.Abs(complex128(u))