/** * Add a Curve * * @param point1 * The first point * @param controlPoint * The control point * @param point2 * The second point */ public void addPoint(Vector3 point1, Vector3 controlPoint, Vector3 point2) { mPoint1 = point1; mControlPoint = controlPoint; mPoint2 = point2; mStartTangent.setAll(controlPoint).subtract(point1); mEndTangent.setAll(point2).subtract(controlPoint); }
/** * Add a Curve * * @param point1 The first point * @param controlPoint1 The first control point * @param controlPoint2 The second control point * @param point2 The second point */ public void addPoint(Vector3 point1, Vector3 controlPoint1, Vector3 controlPoint2, Vector3 point2) { mPoint1 = point1; mControlPoint1 = controlPoint1; mControlPoint2 = controlPoint2; mPoint2 = point2; mStartTangent.setAll(mControlPoint1).subtract(point1); mTransferTangent.setAll(mControlPoint2).subtract(controlPoint1); mEndTangent.setAll(point2).subtract(mControlPoint2); }
/** * Efficient Gram-Schmitt Ortho-normalization for the special case of 2 vectors. * * @param v1 The first {@link Vector3} object to be ortho-normalized. * @param v2 The second {@link Vector3}. {@link Vector3} object to be ortho-normalized. */ public static void orthoNormalize(@NonNull Vector3 v1, @NonNull Vector3 v2) { v1.normalize(); v2.subtract(Vector3.projectAndCreate(v2, v1)); v2.normalize(); }
/** * Applies Gram-Schmitt Ortho-normalization to the given set of input {@link Vector3} objects. * * @param vecs Array of {@link Vector3} objects to be ortho-normalized. */ public static void orthoNormalize(@NonNull @Size(min = 2) Vector3[] vecs) { for (int i = 0; i < vecs.length; ++i) { vecs[i].normalize(); for (int j = i + 1; j < vecs.length; ++j) { vecs[j].subtract(Vector3.projectAndCreate(vecs[j], vecs[i])); } } }
public boolean intersectsWith(IBoundingVolume boundingVolume) { if(!(boundingVolume instanceof BoundingSphere)) return false; BoundingSphere boundingSphere = (BoundingSphere)boundingVolume; mTmpPos.setAll(mPosition); mTmpPos.subtract(boundingSphere.getPosition()); mDist = mTmpPos.x * mTmpPos.x + mTmpPos.y * mTmpPos.y + mTmpPos.z * mTmpPos.z; mMinDist = mRadius * mScale + boundingSphere.getRadius() * boundingSphere.getScale(); return mDist < mMinDist * mMinDist; }
public void calculatePoint(Vector3 result, final double t) { if (mCalculateTangents) { double prevt = t == 0 ? t + DELTA : t - DELTA; double nextt = t == 1 ? t - DELTA : t + DELTA; p(mCurrentTangent, prevt); p(mTempNext, nextt); mCurrentTangent.subtract(mTempNext); mCurrentTangent.multiply(.5); mCurrentTangent.normalize(); } p(result,t); }
v2.y = terrain[x][z]; na = v1.subtract(v0).cross(v2.subtract(v0)); na.inverse(); v2.y = terrain[x + 1][z]; nb = v1.subtract(v0).cross(v2.subtract(v0)); nb.inverse(); v2.y = terrain[x][z + 1]; nc = v1.subtract(v0).cross(v2.subtract(v0)); nc.inverse(); v2.y = terrain[x - 1][z]; nd = v1.subtract(v0).cross(v2.subtract(v0)); nd.inverse();
public boolean isLookingAtObject(Object3D target, float maxAngle) { mHeadViewQuaternion.fromMatrix(mHeadViewMatrix); mHeadViewQuaternion.inverse(); mForwardVec.setAll(0, 0, 1); mForwardVec.rotateBy(mHeadViewQuaternion); mHeadTranslation.setAll(mHeadViewMatrix.getTranslation()); mHeadTranslation.subtract(target.getPosition()); mHeadTranslation.normalize(); return mHeadTranslation.angle(mForwardVec) < maxAngle; } }
@Test public void testSubtractDoublesXyz() { final Vector3 v = new Vector3(1.1d, 2.2d, 3.3d); final Vector3 out = v.subtract(0.1d, 0.2d, 0.3d); assertNotNull(out); assertTrue(out == v); assertEquals(1d, v.x, 0); assertEquals(2d, v.y, 0); assertEquals(3d, v.z, 0); }
@Test public void testSubtractDouble() { final Vector3 v = new Vector3(1.1d, 2.1d, 3.1d); final Vector3 out = v.subtract(0.1d); assertNotNull(out); assertTrue(out == v); assertEquals(1d, v.x, 0); assertEquals(2d, v.y, 0); assertEquals(3d, v.z, 0); }
@Test public void testSubtractVector3() { final Vector3 u = new Vector3(1.1d, 2.2d, 3.3d); final Vector3 v = new Vector3(0.1d, 0.2d, 0.3d); final Vector3 out = u.subtract(v); assertNotNull(out); assertTrue(out == u); assertEquals(1d, u.x, 0); assertEquals(2d, u.y, 0); assertEquals(3d, u.z, 0); }
/** * Applies Gram-Schmitt Ortho-normalization to the given set of input {@link Vector3} objects. * * @param vecs Array of {@link Vector3} objects to be ortho-normalized. */ public static void orthoNormalize(Vector3[] vecs) { for (int i = 0; i < vecs.length; ++i) { vecs[i].normalize(); for (int j = i + 1; j < vecs.length; ++j) { vecs[j].subtract(Vector3.projectAndCreate(vecs[j], vecs[i])); } } }
/** * Efficient Gram-Schmitt Ortho-normalization for the special case of 2 vectors. * * @param v1 The first {@link Vector3} object to be ortho-normalized. * @param v2 The second {@link Vector3}. {@link Vector3} object to be ortho-normalized. */ public static void orthoNormalize(Vector3 v1, Vector3 v2) { v1.normalize(); v2.subtract(Vector3.projectAndCreate(v2, v1)); v2.normalize(); }
public boolean intersectsWith(IBoundingVolume boundingVolume) { if (!(boundingVolume instanceof BoundingSphere)) return false; BoundingSphere boundingSphere = (BoundingSphere) boundingVolume; mTmpPos.setAll(mPosition); mTmpPos.subtract(boundingSphere.getPosition()); mDist = mTmpPos.x * mTmpPos.x + mTmpPos.y * mTmpPos.y + mTmpPos.z * mTmpPos.z; mMinDist = mRadius * mScale + boundingSphere.getRadius() * boundingSphere.getScale(); return mDist < mMinDist * mMinDist; }
public void calculatePoint(Vector3 result, double t) { if (mCalculateTangents) { double prevt = t == 0 ? t + DELTA : t - DELTA; double nextt = t == 1 ? t - DELTA : t + DELTA; p(mCurrentTangent, prevt); p(mTempPointNext, nextt); mCurrentTangent.subtract(mTempPointNext); mCurrentTangent.multiply(.5f); mCurrentTangent.normalize(); } p(result,t); }
public void calculatePoint(Vector3 result, double t) { if (mCalculateTangents) { double prevt = t == 0 ? t + DELTA : t - DELTA; double nextt = t == 1 ? t - DELTA : t + DELTA; p(mCurrentTangent, prevt); p(mTempPointNext, nextt); mCurrentTangent.subtract(mTempPointNext); mCurrentTangent.multiply(.5f); mCurrentTangent.normalize(); } p(result, t); }
public void calculatePoint(Vector3 result, final double t) { if (mCalculateTangents) { double prevt = t == 0 ? t + DELTA : t - DELTA; double nextt = t == 1 ? t - DELTA : t + DELTA; p(mCurrentTangent, prevt); p(mTempNext, nextt); mCurrentTangent.subtract(mTempNext); mCurrentTangent.multiply(.5); mCurrentTangent.normalize(); } p(result,t); }