/** * Sets this {@link Matrix4} to a look at matrix with the given position, target and up {@link Vector3}s. * * @param position {@link Vector3} The eye position. * @param target {@link Vector3} The target position. * @param up {@link Vector3} The up axis. * * @return A reference to this {@link Matrix4} to facilitate chaining. */ @NonNull public Matrix4 setToLookAt(@NonNull Vector3 position, @NonNull Vector3 target, @NonNull Vector3 up) { mVec1.subtractAndSet(target, position); return setToLookAt(mVec1, up); }
public void set(Vector3 point1, Vector3 point2, Vector3 point3) { Vector3 v1 = new Vector3(); Vector3 v2 = new Vector3(); v1.subtractAndSet(point1, point2); v2.subtractAndSet(point3, point2); mNormal = v1.cross(v2); mNormal.normalize(); mD = -point1.dot(mNormal); }
/** * Resets the orientation of this {@link ATransformable3D} object to look at its look at * target and use the specified {@link Vector3} as up. If this is part of a scene graph, * the graph will be notified of the change. * * @param upAxis {@link Vector3} The direction to use as the up axis. * * @return A reference to this {@link ATransformable3D} to facilitate chaining. */ public ATransformable3D resetToLookAt(Vector3 upAxis) { mTempVec.subtractAndSet(mLookAt, mPosition); // In OpenGL, Cameras are defined such that their forward axis is -Z, not +Z like we have defined objects. if (mIsCamera) mTempVec.inverse(); mOrientation.lookAt(mTempVec, upAxis); mLookAtValid = true; markModelMatrixDirty(); return this; }
vertex2.z = mMinorBase * Math.sin(angle0 + side * angle_delta); scratch0.subtractAndSet(vertex0, vertex1); scratch1.subtractAndSet(vertex0, vertex2); temp_normal.crossAndSet(scratch1, scratch0); temp_normal.normalize(); vertex2.y = -mHeight/2.0; vertex2.z = mMinorBase * Math.sin(angle0 + (side + 1) * angle_delta); scratch0.subtractAndSet(vertex2, vertex0); scratch1.subtractAndSet(vertex2, vertex1); temp_normal.crossAndSet(scratch1, scratch0); temp_normal.normalize();
if (!intersectRayPlane(rayStart, rayEnd, p, i)) return false; v0.subtractAndSet(t3, t1); v1.subtractAndSet(t2, t1); v2.subtractAndSet(i, t1);
case 0: //+X/+Y/+Z mMax.setAll(mParent.getMax()); mMin.subtractAndSet(mMax, side_lengths); break; case 1: //-X/+Y/+Z
@Test public void testSubtractAndSet() { final Vector3 u = new Vector3(1.1d, 2.2d, 3.3d); final Vector3 v = new Vector3(0.1d, 0.2d, 0.3d); final Vector3 t = new Vector3(); final Vector3 out = t.subtractAndSet(u, v); assertNotNull(out); assertTrue(out == t); assertEquals(1d, t.x, 0); assertEquals(2d, t.y, 0); assertEquals(3d, t.z, 0); }
public void set(Vector3 point1, Vector3 point2, Vector3 point3) { Vector3 v1 = new Vector3(); Vector3 v2 = new Vector3(); v1.subtractAndSet(point1, point2); v2.subtractAndSet(point3, point2); mNormal = v1.cross(v2); mNormal.normalize(); mD = -point1.dot(mNormal); }
/** * Resets the orientation of this {@link ATransformable3D} object to look at its look at * target and use the specified {@link Vector3} as up. If this is part of a scene graph, * the graph will be notified of the change. * * @param upAxis {@link Vector3} The direction to use as the up axis. * * @return A reference to this {@link ATransformable3D} to facilitate chaining. */ public ATransformable3D resetToLookAt(Vector3 upAxis) { mTempVec.subtractAndSet(mLookAt, mPosition); // In OpenGL, Cameras are defined such that their forward axis is -Z, not +Z like we have defined objects. if (mIsCamera) mTempVec.inverse(); mOrientation.lookAt(mTempVec, upAxis); mLookAtValid = true; markModelMatrixDirty(); return this; }
vertex2.z = mMinorBase * Math.sin(angle0 + side * angle_delta); scratch0.subtractAndSet(vertex0, vertex1); scratch1.subtractAndSet(vertex0, vertex2); temp_normal.crossAndSet(scratch1, scratch0); temp_normal.normalize(); vertex2.y = -mHeight/2.0; vertex2.z = mMinorBase * Math.sin(angle0 + (side + 1) * angle_delta); scratch0.subtractAndSet(vertex2, vertex0); scratch1.subtractAndSet(vertex2, vertex1); temp_normal.crossAndSet(scratch1, scratch0); temp_normal.normalize();
if (!intersectRayPlane(rayStart, rayEnd, p, i)) return false; v0.subtractAndSet(t3, t1); v1.subtractAndSet(t2, t1); v2.subtractAndSet(i, t1);
case 0: //+X/+Y/+Z mMax.setAll(mParent.getMax()); mMin.subtractAndSet(mMax, side_lengths); break; case 1: //-X/+Y/+Z