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