From b0f81a6c7ddef342a152635451aa49bab9c48c2f Mon Sep 17 00:00:00 2001 From: faiface Date: Sun, 20 Nov 2016 19:21:20 +0100 Subject: [PATCH] slightly optimize Vec.Rotated --- vec.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vec.go b/vec.go index b934b42..eaae3eb 100644 --- a/vec.go +++ b/vec.go @@ -27,7 +27,7 @@ import ( // u := pixel.V(2, 3) // v := pixel.V(8, 1) // if u.X() < 0 { -// fmt.Println("this won't happend") +// fmt.Println("this won't happen") // } // x := u.Unit().Dot(v.Unit()) type Vec complex128 @@ -78,7 +78,8 @@ func (u Vec) Scaled(c float64) Vec { // Rotated returns a vector u rotated by the given angle in radians. func (u Vec) Rotated(angle float64) Vec { - return u * V(math.Cos(angle), math.Sin(angle)) + sin, cos := math.Sincos(angle) + return u * V(cos, sin) } // Dot returns the dot product of vectors u and v.