001 package com.croftsoft.core.math.axis;
002
003 import com.croftsoft.core.math.matrix.Matrix3x3Mut;
004 import com.croftsoft.core.math.quat.QuatMut;
005
006 /***********************************************************************
007 * Implementation of interface AxisAngleMut.
008 *
009 * @version
010 * $Id: AxisAngleImp.java,v 1.2 2008/05/09 20:39:38 croft Exp $
011 * @since
012 * 2008-05-09
013 * @author
014 * <a href="http://www.CroftSoft.com/">David Wallace Croft</a>
015 ***********************************************************************/
016
017 public final class AxisAngleImp
018 implements AxisAngleMut
019 ////////////////////////////////////////////////////////////////////////
020 ////////////////////////////////////////////////////////////////////////
021 {
022
023 private double degrees, x, y, z;
024
025 ////////////////////////////////////////////////////////////////////////
026 ////////////////////////////////////////////////////////////////////////
027
028 public AxisAngleImp (
029 final double degrees,
030 final double x,
031 final double y,
032 final double z )
033 ////////////////////////////////////////////////////////////////////////
034 {
035 this.degrees = degrees;
036
037 this.x = x;
038
039 this.y = y;
040
041 this.z = z;
042 }
043
044 public AxisAngleImp ( final AxisAngle axisAngle )
045 ////////////////////////////////////////////////////////////////////////
046 {
047 copy ( axisAngle );
048 }
049
050 public AxisAngleImp ( )
051 ////////////////////////////////////////////////////////////////////////
052 {
053 this ( 0, 1, 0, 0 );
054 }
055
056 ////////////////////////////////////////////////////////////////////////
057 // accessor methods
058 ////////////////////////////////////////////////////////////////////////
059
060 public double getDegrees ( ) { return degrees; }
061
062 public double getX ( ) { return x; }
063
064 public double getY ( ) { return y; }
065
066 public double getZ ( ) { return z; }
067
068 ////////////////////////////////////////////////////////////////////////
069 // mutator methods
070 ////////////////////////////////////////////////////////////////////////
071
072 public void copy ( final AxisAngle axisAngle )
073 ////////////////////////////////////////////////////////////////////////
074 {
075 degrees = axisAngle.getDegrees ( );
076
077 x = axisAngle.getX ( );
078
079 y = axisAngle.getY ( );
080
081 z = axisAngle.getZ ( );
082 }
083
084 public void normalize ( )
085 ////////////////////////////////////////////////////////////////////////
086 {
087 AxisAngleLib.normalize ( this );
088 }
089
090 public void setDegrees ( final double degrees )
091 { this.degrees = degrees; }
092
093 public void setX ( final double x ) { this.x = x; }
094
095 public void setY ( final double y ) { this.y = y; }
096
097 public void setZ ( final double z ) { this.z = z; }
098
099 ////////////////////////////////////////////////////////////////////////
100 // operand methods
101 ////////////////////////////////////////////////////////////////////////
102
103 public boolean matches ( final AxisAngle axisAngle )
104 ////////////////////////////////////////////////////////////////////////
105 {
106 return AxisAngleLib.matches ( this, axisAngle );
107 }
108
109 public boolean matches (
110 final AxisAngle axisAngle,
111 final double tolerance )
112 ////////////////////////////////////////////////////////////////////////
113 {
114 return AxisAngleLib.matches ( this, axisAngle, tolerance );
115 }
116
117 ////////////////////////////////////////////////////////////////////////
118 // calculation methods
119 ////////////////////////////////////////////////////////////////////////
120
121 public double magnitude ( )
122 ////////////////////////////////////////////////////////////////////////
123 {
124 return AxisAngleLib.magnitude ( this );
125 }
126
127 public QuatMut toQuat ( )
128 ////////////////////////////////////////////////////////////////////////
129 {
130 return AxisAngleLib.toQuat ( this );
131 }
132
133 public Matrix3x3Mut toRotationMatrix ( )
134 ////////////////////////////////////////////////////////////////////////
135 {
136 return AxisAngleLib.toRotationMatrix ( this );
137 }
138
139 ////////////////////////////////////////////////////////////////////////
140 // overridden Object methods
141 ////////////////////////////////////////////////////////////////////////
142
143 @Override
144 public String toString ( )
145 ////////////////////////////////////////////////////////////////////////
146 {
147 return AxisAngleLib.toString ( this );
148 }
149
150 ////////////////////////////////////////////////////////////////////////
151 ////////////////////////////////////////////////////////////////////////
152 }