Merge pull request #313 from marc921/add-vec-squared-len
feat(Vec): add squared len method
This commit is contained in:
commit
a9abe2ebb7
|
@ -128,6 +128,11 @@ func (u Vec) Len() float64 {
|
||||||
return math.Hypot(u.X, u.Y)
|
return math.Hypot(u.X, u.Y)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SqLen returns the squared length of the vector u (faster to compute than Len).
|
||||||
|
func (u Vec) SqLen() float64 {
|
||||||
|
return u.X*u.X + u.Y*u.Y
|
||||||
|
}
|
||||||
|
|
||||||
// Angle returns the angle between the vector u and the x-axis. The result is in range [-Pi, Pi].
|
// Angle returns the angle between the vector u and the x-axis. The result is in range [-Pi, Pi].
|
||||||
func (u Vec) Angle() float64 {
|
func (u Vec) Angle() float64 {
|
||||||
return math.Atan2(u.Y, u.X)
|
return math.Atan2(u.Y, u.X)
|
||||||
|
|
Loading…
Reference in New Issue