/** * Convert a vector (in) from world coordinate space to this spatial's local coordinate space. * * @param in * vector to read from * @param store * where to write the result (null to create a new vector, may be same as in) * @return the result (store) */ public Vector3 worldToLocal(final ReadOnlyVector3 in, Vector3 store) { if (store == null) { store = new Vector3(); } return _worldTransform.applyInverse(in, store); }
final Vector3 result3 = trans.applyInverse(vec3, null); assertTrue(Math.abs(new Vector3(-1, -3, 1).distance(result3)) <= MathUtils.EPSILON); trans.applyInverse(vec3, result3); assertTrue(Math.abs(new Vector3(-1, -3, 1).distance(result3)) <= MathUtils.EPSILON); trans.applyInverse(vec3); assertTrue(Math.abs(new Vector3(-1, -3, 1).distance(vec3)) <= MathUtils.EPSILON); final Vector3 orig = new Vector3(vec3); trans.applyForward(vec3); trans.applyInverse(vec3); assertTrue(Math.abs(orig.distance(vec3)) <= 10 * MathUtils.EPSILON); // accumulated error trans.applyForwardVector(vec3); assertEquals(orig, vec3); trans.applyInverse(vec3); assertEquals(orig, vec3); trans.applyInverseVector(vec3);
/** * Convert a vector (in) from world coordinate space to this spatial's local coordinate space. * * @param in * vector to read from * @param store * where to write the result (null to create a new vector, may be same as in) * @return the result (store) */ public Vector3 worldToLocal(final ReadOnlyVector3 in, Vector3 store) { if (store == null) { store = new Vector3(); } return _worldTransform.applyInverse(in, store); }
/** * Applies the inverse of this transform to the given point and returns the result in the given store vector: P' = * M^{-1}*(P-T) * * @param point * @param store * the vector to store our result in. if null, a new vector will be created. * @return the transformed point. * @throws NullPointerException * if point is null. */ @Override public Vector3 applyInverse(final ReadOnlyVector3 point, final Vector3 store) { Vector3 result = store; if (result == null) { result = new Vector3(); } result.set(point); return applyInverse(result); }
/** * Applies the inverse of this transform to the given point and returns the result in the given store vector: P' = * M^{-1}*(P-T) * * @param point * @param store * the vector to store our result in. if null, a new vector will be created. * @return the transformed point. * @throws NullPointerException * if point is null. */ @Override public Vector3 applyInverse(final ReadOnlyVector3 point, final Vector3 store) { Vector3 result = store; if (result == null) { result = new Vector3(); } result.set(point); return applyInverse(result); }
@Test(expected = NullPointerException.class) public void testApplyFail3() { final Transform trans = new Transform(); trans.applyInverse(null); }