Skip to content

Commit 25d2b3b

Browse files
committed
Adds double versions of javajs classes
1 parent 100d648 commit 25d2b3b

File tree

29 files changed

+6705
-1319
lines changed

29 files changed

+6705
-1319
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20220419105639
1+
20220527103831
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20220419105639
1+
20220527103831
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
package javajs.api;
22

33
import javajs.util.V3;
4+
import javajs.util.V3d;
45

56
public interface EigenInterface {
67

78
EigenInterface setM(double[][] n);
89

910
double[] getEigenvalues();
1011

12+
void fillDoubleArrays(V3d[] eigenVectors, double[] eigenValues);
13+
14+
double[][] getEigenvectorsDoubleTransposed();
15+
1116
void fillFloatArrays(V3[] eigenVectors, float[] eigenValues);
1217

1318
float[][] getEigenvectorsFloatTransposed();
1419

20+
1521
}

sources/net.sf.j2s.java.core/src/javajs/api/GenericCifDataParser.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,6 @@ public interface GenericCifDataParser {
4242

4343
String fixKey(String key);
4444

45+
String skipNextToken() throws Exception;
46+
4547
}

sources/net.sf.j2s.java.core/src/javajs/util/A4.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ conforming to the Java(TM) 3D API specification by Sun Microsystems.
1919
import java.io.Serializable;
2020

2121
import javajs.api.JSONEncodable;
22-
import javajs.util.T3;
2322

2423

2524

@@ -117,7 +116,7 @@ public static A4 newVA(V3 axis, float angle) {
117116
a.setVA(axis, angle);
118117
return a;
119118
}
120-
119+
121120
/**
122121
* Sets the value of this AxisAngle4f to the specified axis and angle.
123122
*
@@ -249,4 +248,5 @@ public String toString() {
249248
public String toJSON() {
250249
return "[" + x + "," + y + "," + z + "," + (float) (angle * 180.0 / Math.PI) + "]";
251250
}
251+
252252
}
Lines changed: 255 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
1+
/*
2+
Copyright (C) 1997,1998,1999
3+
Kenji Hiranabe, Eiwa System Management, Inc.
4+
5+
This program is free software.
6+
Implemented by Kenji Hiranabe(hiranabe@esm.co.jp),
7+
conforming to the Java(TM) 3D API specification by Sun Microsystems.
8+
9+
Permission to use, copy, modify, distribute and sell this software
10+
and its documentation for any purpose is hereby granted without fee,
11+
provided that the above copyright notice appear in all copies and
12+
that both that copyright notice and this permission notice appear
13+
in supporting documentation. Kenji Hiranabe and Eiwa System Management,Inc.
14+
makes no representations about the suitability of this software for any
15+
purpose. It is provided "AS IS" with NO WARRANTY.
16+
*/
17+
package javajs.util;
18+
19+
import java.io.Serializable;
20+
21+
import javajs.api.JSONEncodable;
22+
23+
24+
25+
/**
26+
* A 4 element axis angle represented by single precision doubleing point
27+
* x,y,z,angle components. An axis angle is a rotation of angle (radians) about
28+
* the vector (x,y,z).
29+
*
30+
* @version specification 1.1, implementation $Revision: 1.9 $, $Date:
31+
* 2006/07/28 17:01:32 $
32+
* @author Kenji hiranabe
33+
*
34+
* additions by Bob Hanson hansonr@stolaf.edu 9/30/2012
35+
* for unique constructor and method names
36+
* for the optimization of compiled JavaScript using Java2Script
37+
*/
38+
public class A4d implements JSONEncodable, Serializable {
39+
40+
/*
41+
* I assumed that the length of the axis vector is not significant.
42+
*/
43+
44+
/**
45+
* The x coordinate.
46+
*/
47+
public double x;
48+
49+
/**
50+
* The y coordinate.
51+
*/
52+
public double y;
53+
54+
/**
55+
* The z coordinate.
56+
*/
57+
public double z;
58+
59+
/**
60+
* The angle.
61+
*/
62+
public double angle;
63+
64+
/**
65+
* Constructs and initializes a AxisAngle4f to (0,0,1,0).
66+
*/
67+
public A4d() {
68+
z = 1.0d;
69+
}
70+
71+
/**
72+
* Constructs and initializes an AxisAngle4f from the specified x, y, z, and
73+
* angle.
74+
*
75+
* @param x
76+
* the x coordinate
77+
* @param y
78+
* the y coordinate
79+
* @param z
80+
* the z coordinate
81+
* @param angle
82+
* the angle.
83+
* @return a
84+
*/
85+
public static A4d new4(double x, double y, double z, double angle) {
86+
A4d a = new A4d();
87+
a.set4(x, y, z, angle);
88+
return a;
89+
}
90+
91+
/**
92+
* Constructs and initializes a AxisAngle4f from the specified AxisAngle4f.
93+
*
94+
* @param a1
95+
* the AxisAngle4f containing the initialization x y z angle data
96+
* @return a
97+
*/
98+
public static A4d newAA(A4d a1) {
99+
A4d a = new A4d();
100+
a.set4(a1.x, a1.y, a1.z, a1.angle);
101+
return a;
102+
}
103+
104+
/**
105+
* Constructs and initializes an AxisAngle4f from the specified axis and
106+
* angle.
107+
*
108+
* @param axis
109+
* the axis
110+
* @param angle
111+
* the angle
112+
* @return a
113+
*/
114+
public static A4d newVA(V3d axis, double angle) {
115+
A4d a = new A4d();
116+
a.setVA(axis, angle);
117+
return a;
118+
}
119+
120+
/**
121+
* Sets the value of this AxisAngle4f to the specified axis and angle.
122+
*
123+
* @param axis
124+
* the axis
125+
* @param angle
126+
* the angle
127+
* @since Java 3D 1.2
128+
*/
129+
public final void setVA(V3d axis, double angle) {
130+
x = axis.x;
131+
y = axis.y;
132+
z = axis.z;
133+
this.angle = angle;
134+
}
135+
136+
/**
137+
* Sets the value of this axis angle to the specified x,y,z,angle.
138+
*
139+
* @param x
140+
* the x coordinate
141+
* @param y
142+
* the y coordinate
143+
* @param z
144+
* the z coordinate
145+
* @param angle
146+
* the angle
147+
*/
148+
public final void set4(double x, double y, double z, double angle) {
149+
this.x = x;
150+
this.y = y;
151+
this.z = z;
152+
this.angle = angle;
153+
}
154+
155+
/**
156+
* Sets the value of this axis angle to the value of axis angle t1.
157+
*
158+
* @param a
159+
* the axis angle to be copied
160+
*/
161+
public final void setAA(A4d a) {
162+
x = a.x;
163+
y = a.y;
164+
z = a.z;
165+
angle = a.angle;
166+
}
167+
168+
169+
/**
170+
* Sets the value of this axis-angle to the rotational component of the passed
171+
* matrix.
172+
*
173+
* @param m1
174+
* the matrix3f
175+
*/
176+
public final void setM(M3 m1) {
177+
setFromMat(m1.m00, m1.m01, m1.m02, m1.m10, m1.m11, m1.m12, m1.m20, m1.m21,
178+
m1.m22);
179+
}
180+
181+
// helper method
182+
private void setFromMat(double m00, double m01, double m02, double m10,
183+
double m11, double m12, double m20, double m21,
184+
double m22) {
185+
// assuming M is normalized.
186+
187+
double cos = (m00 + m11 + m22 - 1.0) * 0.5;
188+
x = (m21 - m12);
189+
y = (m02 - m20);
190+
z = (m10 - m01);
191+
double sin = 0.5 * Math.sqrt(x * x + y * y + z * z);
192+
if (sin == 0 && cos == 1) {
193+
x = y = 0;
194+
z = 1;
195+
angle = 0;
196+
} else {
197+
angle = Math.atan2(sin, cos);
198+
}
199+
200+
// no need to normalize
201+
// x /= n;
202+
// y /= n;
203+
// z /= n;
204+
}
205+
206+
/**
207+
* Returns a hash number based on the data values in this object. Two
208+
* different AxisAngle4f objects with identical data values (ie, returns true
209+
* for equals(AxisAngle4f) ) will return the same hash number. Two vectors
210+
* with different data members may return the same hash value, although this
211+
* is not likely.
212+
*/
213+
@Override
214+
public int hashCode() {
215+
return T3d.doubleToIntBits(x) ^ T3d.doubleToIntBits(y)
216+
^ T3d.doubleToIntBits(z) ^ T3d.doubleToIntBits(angle);
217+
}
218+
219+
/**
220+
* Returns true if the Object o is of type AxisAngle4f and all of the data
221+
* members of o1 are equal to the corresponding data members in this
222+
* AxisAngle4f.
223+
*
224+
* @param o
225+
* the object with which the comparison is made.
226+
* @return T/F
227+
*/
228+
@Override
229+
public boolean equals(Object o) {
230+
if (!(o instanceof A4d))
231+
return false;
232+
A4d a1 = (A4d) o;
233+
return x == a1.x && y == a1.y && z == a1.z && angle == a1.angle;
234+
}
235+
236+
/**
237+
* Returns a string that contains the values of this AxisAngle4f. The form is
238+
* (x,y,z,angle).
239+
*
240+
* @return the String representation
241+
*/
242+
@Override
243+
public String toString() {
244+
return "(" + x + ", " + y + ", " + z + ", " + angle + ")";
245+
}
246+
247+
@Override
248+
public String toJSON() {
249+
return "[" + x + "," + y + "," + z + "," + (angle * 180.0 / Math.PI) + "]";
250+
}
251+
252+
public void setM(M3d m3) {
253+
setM(m3.toM3());
254+
}
255+
}

0 commit comments

Comments
 (0)