001 package com.croftsoft.core.math.quat;
002
003 import com.croftsoft.core.math.axis.AxisAngle;
004
005 /***********************************************************************
006 * Quat test methods.
007 *
008 * @version
009 * $Id: QuatTest.java,v 1.6 2008/09/20 04:12:46 croft Exp $
010 * @since
011 * 2008-05-02
012 * @author
013 * <a href="http://www.CroftSoft.com/">David Wallace Croft</a>
014 ***********************************************************************/
015
016 public final class QuatTest
017 ////////////////////////////////////////////////////////////////////////
018 ////////////////////////////////////////////////////////////////////////
019 {
020
021 public static void main ( final String [ ] args )
022 ////////////////////////////////////////////////////////////////////////
023 {
024 System.out.println ( test ( ) );
025 }
026
027 public static boolean test ( )
028 ////////////////////////////////////////////////////////////////////////
029 {
030 return testMultiply ( );
031 }
032
033 public static boolean testMultiply ( )
034 ////////////////////////////////////////////////////////////////////////
035 {
036 final Quat quatX90 = QuatLib.fromEulerAngles ( 90, 0, 0 );
037
038 System.out.println ( "X90 ...........: " + quatX90 );
039
040 final Quat quatX180 = QuatLib.fromEulerAngles ( 180, 0, 0 );
041
042 System.out.println ( "X180 ..........: " + quatX180 );
043
044 final Quat quatX90X90 = quatX90.multiply ( quatX90 );
045
046 System.out.println ( "X90,X90 .......: " + quatX90X90 );
047
048 final Quat quatY90 = QuatLib.fromEulerAngles ( 0, 90, 0 );
049
050 System.out.println ( "Y90 ...........: " + quatY90 );
051
052 final Quat quatZ90 = QuatLib.fromEulerAngles ( 0, 0, 90 );
053
054 System.out.println ( "Z90 ...........: " + quatZ90 );
055
056 final Quat quatX90Y90Z90 = QuatLib.fromEulerAngles ( 90, 90, 90 );
057
058 System.out.println ( "X90,Y90,Z90 ...: " + quatX90Y90Z90 );
059
060 final AxisAngle axisAngle = quatX90Y90Z90.toAxisAngle ( );
061
062 System.out.printf (
063 "rotation degrees = %1$1.3f\n",
064 new Double ( axisAngle.getDegrees ( ) ) );
065
066 System.out.printf (
067 "rotation axis = %1$1.3f %2$1.3f %3$1.3f\n",
068 new Double ( axisAngle.getX ( ) ),
069 new Double ( axisAngle.getY ( ) ),
070 new Double ( axisAngle.getZ ( ) ) );
071
072 return quatX180.matches ( quatX90X90, 0.001 );
073 }
074
075 ////////////////////////////////////////////////////////////////////////
076 // private methods
077 ////////////////////////////////////////////////////////////////////////
078
079 private QuatTest ( )
080 ////////////////////////////////////////////////////////////////////////
081 {
082 // empty
083 }
084
085 ////////////////////////////////////////////////////////////////////////
086 ////////////////////////////////////////////////////////////////////////
087 }