Skip to content

Commit

Permalink
Resolve failing unit test from vecmath bug. Looks to be a bug in the …
Browse files Browse the repository at this point in the history
…64-bit (double) rotation, using the 32-bit (float) transformation gives the expected and correct value.
  • Loading branch information
johnmay committed Dec 30, 2014
1 parent a2ebdef commit 5d22594
Showing 1 changed file with 9 additions and 5 deletions.
Expand Up @@ -23,9 +23,12 @@
package org.openscience.cdk.geometry;

import javax.vecmath.AxisAngle4d;
import javax.vecmath.AxisAngle4f;
import javax.vecmath.Matrix3d;
import javax.vecmath.Matrix3f;
import javax.vecmath.Point3d;
import javax.vecmath.Vector3d;
import javax.vecmath.Vector3f;

/**
* A set of static utility classes for dealing with Z matrices.
Expand Down Expand Up @@ -91,11 +94,12 @@ public static Point3d[] zmatrixToCartesian(double[] distances, int[] first_atoms
}

private static Vector3d rotate(Vector3d vector, Vector3d axis, double angle) {
Matrix3d rotate = new Matrix3d();
rotate.set(new AxisAngle4d(axis, Math.toRadians(angle)));
Vector3d result = new Vector3d();
rotate.transform(vector, result);
return result;
Matrix3f rotate = new Matrix3f();
rotate.set(new AxisAngle4f(new Vector3f(axis), (float) Math.toRadians(angle)));
Vector3f result = new Vector3f();
Vector3f vector3f = new Vector3f(vector);
rotate.transform(vector3f, result);
return new Vector3d(result);
}

}

0 comments on commit 5d22594

Please sign in to comment.