// ExtractEulerAngles extracts the rotation part of the matrix as Euler angle rotation values. func (mat *T) ExtractEulerAngles() (yHead, xPitch, zRoll float32) { xPitch = math.Asin(mat[1][2]) f12 := math.Abs(mat[1][2]) if f12 > (1.0-0.0001) && f12 < (1.0+0.0001) { // f12 == 1.0 yHead = 0.0 zRoll = math.Atan2(mat[0][1], mat[0][0]) } else { yHead = math.Atan2(-mat[0][2], mat[2][2]) zRoll = math.Atan2(-mat[1][0], mat[1][1]) } return yHead, xPitch, zRoll }
// Angle returns the counter-clockwise angle of the vector from the x axis. func (vec *T) Angle() float32 { return math.Atan2(vec[1], vec[0]) }