private void button4_Click(object sender, EventArgs e) { ClearPictureBox(); // Setup Orig Vector MyVector origVector = new MyVector(9, 0, 0); DrawVector(origVector, Color.Silver); MyQuaternion multiRotationQuat = new MyQuaternion(new MyVector(0, 0, 0), Utility3D.GetDegreesToRadians(0)); // Rotate around Z MyQuaternion anotherRotationQuat = new MyQuaternion(new MyVector(0, 0, 1), Utility3D.GetDegreesToRadians(1)); //List<double> lengths = new List<double>(); for (int outerCntr = 1; outerCntr <= 100000; outerCntr++) { //lengths.Add(multiRotationQuat.GetMagnitude()); for (int innerCntr = 1; innerCntr <= 360; innerCntr++) { multiRotationQuat = MyQuaternion.Multiply(anotherRotationQuat, multiRotationQuat); } //multiRotationQuat.BecomeUnitQuaternion(); } // Draw the final output MyVector subRotation = multiRotationQuat.GetRotatedVector(origVector, true); DrawVector(subRotation, Color.Yellow); }
private void button3_Click(object sender, EventArgs e) { ClearPictureBox(); // Setup Orig Vector MyVector origVector = new MyVector(9, 0, 0); DrawVector(origVector, Color.Silver); #region Single Rotation // Setup quat to do the whole rotation in one shot MyQuaternion largeRotationQuat = new MyQuaternion(new MyVector(0, 0, 1), Utility3D.GetDegreesToRadians(90)); MyVector largeRotation = largeRotationQuat.GetRotatedVector(origVector, true); DrawVector(largeRotation, Color.White); #endregion #region Multi Rotations // Setup quat that holds a 30 degree angle MyQuaternion multiRotationQuat = new MyQuaternion(new MyVector(0, 0, 1), Utility3D.GetDegreesToRadians(30)); MyVector subRotation = multiRotationQuat.GetRotatedVector(origVector, true); DrawVector(subRotation, Color.Orange); // Setup a quat that holds a 1 degree angle MyQuaternion anotherRotationQuat = new MyQuaternion(new MyVector(0, 0, 1), Utility3D.GetDegreesToRadians(1)); // Apply this to the multi quat 60 times for (int cntr = 1; cntr <= 60; cntr++) { multiRotationQuat = MyQuaternion.Multiply(anotherRotationQuat, multiRotationQuat); } // Let's see what happened subRotation = multiRotationQuat.GetRotatedVector(origVector, true); DrawVector(subRotation, Color.HotPink); #endregion #region Multi Rotations (3D) /* * // Rotate around Y * multiRotationQuat = new MyQuaternion(new MyVector(0, 1, 0), Utility3D.GetDegreesToRadians(90)); * * // Rotate around X * anotherRotationQuat = new MyQuaternion(new MyVector(1, 0, 0), Utility3D.GetDegreesToRadians(90)); * multiRotationQuat = MyQuaternion.Multiply(anotherRotationQuat, multiRotationQuat); * * // Draw the final output * subRotation = multiRotationQuat.GetRotatedVector(origVector, true); * DrawVector(subRotation, Color.Yellow); */ #endregion #region Multi Rotations (Vector3D) /* * subRotation = origVector.Clone(); * * subRotation.RotateAroundAxis(new MyVector(0, 1, 0), Utility3D.GetDegreesToRadians(90)); * subRotation.RotateAroundAxis(new MyVector(1, 0, 0), Utility3D.GetDegreesToRadians(90)); * * DrawVector(subRotation, Color.Yellow); */ #endregion }