// Sets this matrix to a rotation matrix that will rotate any vector in counter-clockwise direction around the z-axis. // param radians The angle in radians. // return This matrix for the purpose of chaining operations. func (self *Affine2) SetToRotationRad(radians float32) *Affine2 { cos := utils.Cos(radians) sin := utils.Sin(radians) self.m00 = cos self.m01 = -sin self.m02 = 0 self.m10 = sin self.m11 = cos self.m12 = 0 return self }
// Postmultiplies this matrix with a (counter-clockwise) rotation matrix. // param radians The angle in radians // return This matrix for the purpose of chaining. func (self *Affine2) RotateRad(radians float32) *Affine2 { if radians == 0 { return self } cos := utils.Cos(radians) sin := utils.Sin(radians) tmp00 := self.m00*cos + self.m01*sin tmp01 := self.m00*-sin + self.m01*cos tmp10 := self.m10*cos + self.m11*sin tmp11 := self.m10*-sin + self.m11*cos self.m00 = tmp00 self.m01 = tmp01 self.m10 = tmp10 self.m11 = tmp11 return self }
// Sets this matrix to a concatenation of translation, rotation and scale. It is a more efficient form for: // <code>idt().translate(x, y).rotateRad(radians).scale(scaleX, scaleY)</code> // param x The translation in x. // param y The translation in y. // param radians The angle in radians. // param scaleX The scale in y. // param scaleY The scale in x. // return This matrix for the purpose of chaining operations. func (self *Affine2) SetToTrnRotRadScl(x, y, radians, scaleX, scaleY float32) *Affine2 { self.m02 = x self.m12 = y if radians == 0 { self.m00 = scaleX self.m01 = 0 self.m10 = 0 self.m11 = scaleY } else { sin := utils.Sin(radians) cos := utils.Cos(radians) self.m00 = cos * scaleX self.m01 = -sin * scaleY self.m10 = sin * scaleX self.m11 = cos * scaleY } return self }
// Premultiplies this matrix with a (counter-clockwise) rotation matrix. // param radians The angle in radians // return This matrix for the purpose of chaining. func (self *Affine2) PreRotateRad(radians float32) *Affine2 { if radians == 0 { return self } cos := utils.Cos(radians) sin := utils.Sin(radians) tmp00 := cos*self.m00 - sin*self.m10 tmp01 := cos*self.m01 - sin*self.m11 tmp02 := cos*self.m02 - sin*self.m12 tmp10 := sin*self.m00 + cos*self.m10 tmp11 := sin*self.m01 + cos*self.m11 tmp12 := sin*self.m02 + cos*self.m12 self.m00 = tmp00 self.m01 = tmp01 self.m02 = tmp02 self.m10 = tmp10 self.m11 = tmp11 self.m12 = tmp12 return self }