/** * Performs a linear interpolation between this {@link Vector3} and to by the specified amount. * The result will be stored in the current object which means that the current * x, y, z values will be overridden. * * @param target {@link Vector3} Ending point. * @param t double [0-1] interpolation value. * * @return A reference to this {@link Vector3} to facilitate chaining. */ @NonNull public Vector3 lerp(@NonNull Vector3 target, double t) { return multiply(1.0 - t).add(target.x * t, target.y * t, target.z * t); }
public void calculatePoint(Vector3 result, double t) { mCurrent = t; if(mCurrent <0) mCurrent=0; if(mCurrent >1) mCurrent=1; mTmpPoint1.setAll(mPoint1); mTmpPoint1.multiply((1-mCurrent) * (1-mCurrent)); mTmpPoint2.setAll(mControlPoint); mTmpPoint2.multiply(2 * (1-mCurrent) * t); mTmpPoint3.setAll(mPoint2); mTmpPoint3.multiply(mCurrent * mCurrent); mTmpPoint2.add(mTmpPoint3); result.addAndSet(mTmpPoint1, mTmpPoint2); }
position.add(pos);
public void calculatePoint(Vector3 result, double t) { double u = 1 - t; double tt = t * t; double uu = u * u; double ttt = tt * t; double uuu = uu * u; result.scaleAndSet(mPoint1, uuu); mTempPoint.scaleAndSet(mControlPoint1, 3 * uu * t); result.add(mTempPoint); mTempPoint.scaleAndSet(mControlPoint2, 3 * u * tt); result.add(mTempPoint); mTempPoint.scaleAndSet(mPoint2, ttt); result.add(mTempPoint); mCurrent = t; }
private boolean getIntersection( double fDst1, double fDst2, Vector3 P1, Vector3 P2) { if ((fDst1 * fDst2) >= 0.0f) return false; if (floatEqual(fDst1, fDst2)) return false; mHitPoint.multiply(0); mHitPoint.add(Vector3.subtractAndCreate(P2, P1)); mHitPoint.multiply(-fDst1/(fDst2-fDst1)); mHitPoint.add(P1); return true; }
@Override protected void applyTransformation() { synchronized (mCoalesceObjects) { synchronized (mThetaRanges) { int i; final int j = mCoalesceObjects.size(); for (i = 0; i < j; ++i) { // Retrieve the configuration CoalesceConfig config = mCoalesceObjects.get(i); double theta = mThetaRanges.get(i) * mInterpolatedTime; // Calculate the next point config.spiral.calculatePoint(config.object.getPosition(), theta); // Add the coalesce point to translate our spiral config.object.getPosition().add(config.coalesceAroundPoint); } } } }
/** * Multiplies this {@link Quaternion} by a {@link Vector3}. * Note that if you plan on using the returned {@link Vector3}, * you should clone it immediately as it is an internal scratch * member of this {@link Quaternion} and may be modified at any * time. This is the same as out = q*vector*`q, meaning the magnitude * will be maintained. * * @param vector {@link Vector3} to multiply by. * * @return {@link Vector3} The result of the multiplication. */ @NonNull public Vector3 multiply(@NonNull Vector3 vector) { mTmpVec3.setAll(x, y, z); mTmpVec1.crossAndSet(mTmpVec3, vector); mTmpVec2.crossAndSet(mTmpVec3, mTmpVec1); mTmpVec1.multiply(2.0 * w); mTmpVec2.multiply(2.0); mTmpVec1.add(mTmpVec2); mTmpVec1.add(vector); return mTmpVec1; }
public Vector3 getCurrentTangent() { double t = mCurrent; Vector3 startPortion = new Vector3(mStartTangent).multiply(3*(1-t)*(1-t)); Vector3 transferPortion = new Vector3(mTransferTangent).multiply(6*(1-t)*t); Vector3 endPortion = new Vector3(mEndTangent).multiply(3*t*t); Vector3 result = startPortion.add(transferPortion).add(endPortion); result.normalize(); return result; }
vertexNormal.add(normals[j / 3]);
/** * Utility method to move the specified number of units along the current right axis. This will * also adjust the look at target (if a valid one is currently set). * * @param units {@code double} Number of units to move. If negative, movement will be in the "left" direction. */ public void moveRight(double units) { mTempVec.setAll(WorldParameters.RIGHT_AXIS); mTempVec.rotateBy(mOrientation).normalize(); mTempVec.multiply(units); mPosition.add(mTempVec); if (mLookAtValid) { mLookAt.add(mTempVec); resetToLookAt(); } markModelMatrixDirty(); }
/** * Utility method to move the specified number of units along the current forward axis. This will * also adjust the look at target (if a valid one is currently set). * * @param units {@code double} Number of units to move. If negative, movement will be in the "back" direction. */ public void moveForward(double units) { mTempVec.setAll(WorldParameters.FORWARD_AXIS); mTempVec.rotateBy(mOrientation).normalize(); mTempVec.multiply(units); mPosition.add(mTempVec); if (mLookAtEnabled && mLookAtValid) { mLookAt.add(mTempVec); resetToLookAt(); } markModelMatrixDirty(); }
/** * Utility method to move the specified number of units along the current up axis. This will * also adjust the look at target (if a valid one is currently set). * * @param units {@code double} Number of units to move. If negative, movement will be in the "down" direction. */ public void moveUp(double units) { mTempVec.setAll(WorldParameters.UP_AXIS); mTempVec.rotateBy(mOrientation).normalize(); mTempVec.multiply(units); mPosition.add(mTempVec); if (mLookAtEnabled && mLookAtValid) { mLookAt.add(mTempVec); resetToLookAt(); } markModelMatrixDirty(); }
public Vector3 getCurrentTangent() { Vector3 startPortion = new Vector3(mStartTangent).multiply(1-mCurrent); Vector3 endPortion = new Vector3(mEndTangent).multiply(mCurrent); Vector3 result = startPortion.add(endPortion); result.normalize(); return result; }
normal.inverse(); mesh.boneVertices[index0].normal.add(normal); mesh.boneVertices[index1].normal.add(normal); mesh.boneVertices[index2].normal.add(normal); SkeletonJoint joint = mJoints[weight.jointIndex]; vert.normal.add(Vector3.scaleAndCreate(joint.getOrientation().multiply(normal), weight.weightValue));
@Test public void testAddDoublesXyz() { final Vector3 v = new Vector3(1d, 2d, 3d); final Vector3 out = v.add(0.1d, 0.2d, 0.3d); assertNotNull(out); assertTrue(out == v); assertEquals(1.1d, v.x, 0); assertEquals(2.2d, v.y, 0); assertEquals(3.3d, v.z, 0); }
@Test public void testAddDouble() { final Vector3 v = new Vector3(1d, 2d, 3d); final Vector3 out = v.add(0.1d); assertNotNull(out); assertTrue(out == v); assertEquals(1.1d, v.x, 0); assertEquals(2.1d, v.y, 0); assertEquals(3.1d, v.z, 0); }
@Test public void testAddVector3() { final Vector3 u = new Vector3(1d, 2d, 3d); final Vector3 v = new Vector3(0.1d, 0.2d, 0.3d); final Vector3 out = u.add(v); assertNotNull(out); assertTrue(out == u); assertEquals(1.1d, u.x, 0); assertEquals(2.2d, u.y, 0); assertEquals(3.3d, u.z, 0); }
@Override public void onDrawEye(Eye eye) { getCurrentCamera().updatePerspective( eye.getFov().getLeft(), eye.getFov().getRight(), eye.getFov().getBottom(), eye.getFov().getTop()); mCurrentEyeMatrix.setAll(eye.getEyeView()); mCurrentEyeOrientation.fromMatrix(mCurrentEyeMatrix); getCurrentCamera().setOrientation(mCurrentEyeOrientation); getCurrentCamera().setPosition(mCameraPosition); getCurrentCamera().getPosition().add(mCurrentEyeMatrix.getTranslation().inverse()); super.onRenderFrame(null); }
mFrustumCentroid.add(mFrustumCorners[i]); mFrustumCentroid.divide(8.0);