1 package com.insanityengine.ghia.m3;
2
3 import com.insanityengine.ghia.libograf.State;
4
5 /***
6 *
7 * <P>
8 * </P>
9 *
10 *
11 * @author BrianHammond
12 *
13 * $Header: /usr/local/cvsroot/ghia/src/java/com/insanityengine/ghia/m3/Quaternion.java,v 1.4 2005/03/19 17:50:02 brian Exp $
14 *
15 */
16 public class Quaternion implements State {
17
18 /***
19 *
20 * Constructor
21 *
22 */
23 public Quaternion() {
24 quat = new Quat();
25 ws1 = new Quat();
26 ws2 = new Quat();
27 ws3 = new Quat();
28 }
29
30 /***
31 *
32 * identity
33 *
34 * @return a State
35 *
36 */
37 public State identity() {
38 quat.identity();
39 return this;
40 }
41
42 /***
43 *
44 * rotate
45 *
46 * @param angle
47 *
48 * @return a State
49 *
50 */
51 public State rotate( Pt3 angle ) {
52 quat.rotate( angle, ws1, ws2, ws3 );
53 return this;
54 }
55
56 /***
57 *
58 * translate
59 *
60 * @param displacement
61 *
62 * @return a State
63 *
64 */
65 public State translate( Pt3 displacement ) {
66 quat.translate( displacement );
67 return this;
68 }
69
70 /***
71 *
72 * scale
73 *
74 * @param ratio
75 *
76 * @return a State
77 *
78 */
79 public State scale( Pt3 ratio ) {
80 quat.scale( ratio );
81 return this;
82 }
83
84 /***
85 *
86 * multiply: this = this * state
87 *
88 * @param state
89 *
90 * @return this State
91 *
92 */
93 public State multiply( State state ) {
94 quat.multiply(
95 ws1.set( quat )
96 ,
97 ( ( Quaternion ) state ).quat
98 );
99 quat.normalize();
100 return this;
101 }
102
103 /***
104 *
105 * set
106 *
107 * @param state
108 *
109 * @return this State
110 *
111 */
112 public State set( State state ) {
113 quat.set( ( ( Quaternion ) state ).quat );
114 return this;
115 }
116
117 /***
118 *
119 * multiply
120 *
121 * @param point
122 * @param destination
123 *
124 * @return a Pt3
125 *
126 */
127 public Pt3 multiply( Pt3 point, Pt3 destination ) {
128 return quat.multiply( point, destination, ws1, ws2, ws3 );
129 }
130
131
132
133 private Quat quat, ws1, ws2, ws3;
134
135 };
136
137 /***
138 *
139 * $Log: Quaternion.java,v $
140 * Revision 1.4 2005/03/19 17:50:02 brian
141 * repackaging
142 *
143 * Revision 1.3 2005/03/15 05:45:55 brian
144 * closer...
145 *
146 * Revision 1.1 2005/03/12 04:51:28 brian
147 * right or wrong, here they are...
148 *
149 *
150 */