GithubHelp home page GithubHelp logo

vecmath's People

Contributors

hharrison avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vecmath's Issues

Java 10 compatibility?

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?

One Tuple class to rule them all

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.

Issue with Matrix4f#get(Quat4f), Matrix4d#get(Quat4f) and probably Matrix4d#get(Quat4d)

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);
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.