hharrison / vecmath Goto Github PK
View Code? Open in Web Editor NEWFork of the javax.vecmath package
License: GNU General Public License v2.0
Fork of the javax.vecmath package
License: GNU General Public License v2.0
I'd like to be able to write methods like this:
public static <T> Tuple<T> average(Tuple<T>... tuples) {
...rather than writing multiple methods to handle the different types of Tuples.
This could be accomplished by declaring a new Tuple class that Tuple3d, Tuple2f, etc. will extend, like so:
public class Tuple<T extends Tuple<T>> {
And in the extending classes:
public class Tuple3f extends Tuple<Tuple3f> {
If you like the idea, I might fork the project and work on it myself.
We are struggling to use vecmath with Java 9 and Java 10.
The issue that we see is:
BUILD SUCCESSFUL
Total time: 3 seconds
Exception in thread "main" java.lang.NoClassDefFoundError: javax/vecmath/Tuple3d
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:374)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)
Caused by: java.lang.ClassNotFoundException: javax.vecmath.Tuple3d
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:566)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
... 3 more
Exception in thread "main" java.lang.NoClassDefFoundError: javax/vecmath/Tuple3d
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:374)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)
Caused by: java.lang.ClassNotFoundException: javax.vecmath.Tuple3d
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:566)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
... 3 more
This even happens when I recompile vecmath from source in Java 10 and copy the jar over.
I have to use this patch:
diff --git a/build.xml b/build.xml
index da02748..9a60efa 100644
--- a/build.xml
+++ b/build.xml
@@ -22,7 +22,7 @@
<mkdir dir="${class.dir}"/>
<javac srcdir="${src.dir}" destdir="${class.dir}"
- source="1.5" target="1.5"
+ source="1.8" target="1.8"
debug="true"
debuglevel="lines,source"
deprecation="on"
ant compile
ant jar
cp build/jars/vecmath.jar ../wherever
Is this a known issue?
There is an issue where Matrix4f#get(Quat4f) will returns NaN as the quaternion. The issue is related to the ww calculation that can ends up with a negative value. This situation was taken care by the if statement using a ternary operator but not by the Math.sqrt juste below, where the code passes the ww value without consideration for possible negative values.
Simply replacing Math.sqrt(ww) by Math.sqrt(Math.abs(ww)) solved the issue. Even though the get didn't return exactly the same quaternion, it returned an equivalent such as applying both quaternion to the same vector will return the same transformed vector.
To test the issue:
import javax.vecmath.Matrix4d;
import javax.vecmath.Matrix4f;
import javax.vecmath.Quat4f;
import javax.vecmath.Vector3d;
import javax.vecmath.Vector3f;
public class Test {
public static void main(String args[]) {
testBogus(new Quat4f(0.6464f, -0.0189f, 0.76269996f, 0.0002f));
testBogusDouble(new Quat4f(0.6464f, -0.0189f, 0.76269996f, 0.0002f));
}
public static void testBogus(Quat4f q) {
Vector3f v = new Vector3f(1,0,0);
Quat4f qt = new Quat4f();
Quat4f n = new Quat4f(q);
Matrix4f pose = new Matrix4f();
n.normalize();
pose.set(n);
pose.transform(v);
pose.get(qt);
// pose.transform returns a vector but qt is now NaN
System.out.println(qt + " " + v);
}
public static void testBogusDouble(Quat4f q) {
Vector3d v = new Vector3d(1,0,0);
Quat4f qt = new Quat4f();
Quat4f n = new Quat4f(q);
Matrix4d pose = new Matrix4d();
n.normalize();
pose.set(n);
pose.transform(v);
pose.get(qt);
// pose.transform returns a vector but qt is now NaN
System.out.println(qt + " " + v);
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.