/// <summary> /// Rotates this instance by x degrees. /// </summary> /// <param name="degrees">Amount to rotate relative to current rotation.</param> /// <returns>Number of rotations performed.</returns> public int Rotate(double degrees) { int output = 0; float use = Convert.ToSingle(StaticMethods.DegToRad(degrees)); for (int t = 0; t < _TimeCollection.Count; t++) { for (int b = 0; b < _TimeCollection[t].Bones.Count; b++) { if (_NodeCollection[_TimeCollection[t].Bones[b].Node].Parent == -1) { // Z Rotation _TimeCollection[t].Bones[b].Rotation.Z += use; // Get start quadrant. StaticMethods.Quadrant quad = StaticMethods.GetQuadrant(_TimeCollection[t].Bones[b].Position.X, _TimeCollection[t].Bones[b].Position.Y); // X, Y Position double hypotenuse = Math.Sqrt(Math.Pow(_TimeCollection[t].Bones[b].Position.X, 2) + Math.Pow(_TimeCollection[t].Bones[b].Position.Y, 2)); double rad = Math.Atan(_TimeCollection[t].Bones[b].Position.Y / _TimeCollection[t].Bones[b].Position.X); rad += use; _TimeCollection[t].Bones[b].Position.X = Convert.ToSingle(Math.Cos(rad) * hypotenuse); _TimeCollection[t].Bones[b].Position.Y = Convert.ToSingle(Math.Sin(rad) * hypotenuse); // Correct for the -x quadrants if ((quad == StaticMethods.Quadrant.II) || (quad == StaticMethods.Quadrant.III)) { _TimeCollection[t].Bones[b].Position.X *= -1; _TimeCollection[t].Bones[b].Position.Y *= -1; } output++; } } } return(output); }