/** * @param vec * @return this vector, set to the cross product of this vector with the given vector's x, y, z values * @throws NullPointerException * if vec is null. */ public Vector3 crossLocal(final ReadOnlyVector3 vec) { return crossLocal(vec.getX(), vec.getY(), vec.getZ()); }
/** * @param vec * @return this vector, set to the cross product of this vector with the given vector's x, y, z values * @throws NullPointerException * if vec is null. */ public Vector3 crossLocal(final ReadOnlyVector3 vec) { return crossLocal(vec.getX(), vec.getY(), vec.getZ()); }
/** * Computes the normal from the three vertices in the given array that are indexed by the edges. * * @param verts * The array containing the vertices */ public void computeNormal(final Vector3[] verts) { final int i0 = edges[0].i0; final int i1 = edges[1].i0; final int i2 = edges[2].i0; verts[i2].subtract(verts[i1], _compVect0); verts[i0].subtract(verts[i1], _compVect1); normal.set(_compVect0.crossLocal(_compVect1)).normalizeLocal(); }
/** * Computes the normal from the three vertices in the given array that are indexed by the edges. * * @param verts * The array containing the vertices */ public void computeNormal(final Vector3[] verts) { final int i0 = edges[0].i0; final int i1 = edges[1].i0; final int i2 = edges[2].i0; verts[i2].subtract(verts[i1], _compVect0); verts[i0].subtract(verts[i1], _compVect1); normal.set(_compVect0.crossLocal(_compVect1)).normalizeLocal(); }
/** * Aligns this Billboard Node so that it points to the camera position. */ private void rotateCameraAligned() { final Camera camera = Camera.getCurrentCamera(); _look.set(camera.getLocation()).subtractLocal(_worldTransform.getTranslation()).normalizeLocal(); _left.set(camera.getUp()).crossLocal(_look); final Vector3 up = Vector3.fetchTempInstance(); up.set(_look).crossLocal(_left); _orient.fromAxes(_left, up, _look); if(_localRot != null) _orient.multiplyLocal(_localRot); _worldTransform.setRotation(_orient); Vector3.releaseTempInstance(up); }
trailDirection.crossLocal(trailCamVec); trailDirection.normalizeLocal().multiplyLocal(trailData.width * 0.5); } else if (trailData.tangent != null) {
/** * Recalculates the surface normal of the triangle by crossing the vectors formed by BA and CA. */ protected void calculateNormal() { if (_normal == null) { _normal = _pointB.clone(); } else { _normal.set(_pointB); } _normal.subtractLocal(_pointA).crossLocal(_pointC.getX() - _pointA.getX(), _pointC.getY() - _pointA.getY(), _pointC.getZ() - _pointA.getZ()); _normal.normalizeLocal(); _dirtyNormal = false; }
/** * Recalculates the surface normal of the triangle by crossing the vectors formed by BA and CA. */ protected void calculateNormal() { if (_normal == null) { _normal = _pointB.clone(); } else { _normal.set(_pointB); } _normal.subtractLocal(_pointA).crossLocal(_pointC.getX() - _pointA.getX(), _pointC.getY() - _pointA.getY(), _pointC.getZ() - _pointA.getZ()); _normal.normalizeLocal(); _dirtyNormal = false; }
/** * Sets this plane to the plane defined by the given three points. * * @param pointA * @param pointB * @param pointC * @return this plane for chaining * @throws NullPointerException * if one or more of the points are null. */ public Plane setPlanePoints(final ReadOnlyVector3 pointA, final ReadOnlyVector3 pointB, final ReadOnlyVector3 pointC) { _normal.set(pointB).subtractLocal(pointA); _normal.crossLocal(pointC.getX() - pointA.getX(), pointC.getY() - pointA.getY(), pointC.getZ() - pointA.getZ()) .normalizeLocal(); _constant = _normal.dot(pointA); return this; }
/** * Sets this plane to the plane defined by the given three points. * * @param pointA * @param pointB * @param pointC * @return this plane for chaining * @throws NullPointerException * if one or more of the points are null. */ public Plane setPlanePoints(final ReadOnlyVector3 pointA, final ReadOnlyVector3 pointB, final ReadOnlyVector3 pointC) { _normal.set(pointB).subtractLocal(pointA); _normal.crossLocal(pointC.getX() - pointA.getX(), pointC.getY() - pointA.getY(), pointC.getZ() - pointA.getZ()) .normalizeLocal(); _constant = _normal.dot(pointA); return this; }
/** * Modifies this matrix to equal the rotation required to point the z-axis at 'direction' and the y-axis to 'up'. * * @param direction * where to 'look' at * @param up * a vector indicating the local up direction. * @return this matrix for chaining */ public Matrix3 lookAt(final ReadOnlyVector3 direction, final ReadOnlyVector3 up) { final Vector3 xAxis = Vector3.fetchTempInstance(); final Vector3 yAxis = Vector3.fetchTempInstance(); final Vector3 zAxis = Vector3.fetchTempInstance(); direction.normalize(zAxis); up.normalize(xAxis).crossLocal(zAxis).normalizeLocal(); zAxis.cross(xAxis, yAxis); fromAxes(xAxis, yAxis, zAxis); Vector3.releaseTempInstance(xAxis); Vector3.releaseTempInstance(yAxis); Vector3.releaseTempInstance(zAxis); return this; }
/** * Modifies this quaternion to equal the rotation required to point the z-axis at 'direction' and the y-axis to * 'up'. * * @param direction * where to 'look' at * @param up * a vector indicating the local up direction. * @return this quaternion for chaining. */ public Quaternion lookAt(final ReadOnlyVector3 direction, final ReadOnlyVector3 up) { final Vector3 xAxis = Vector3.fetchTempInstance(); final Vector3 yAxis = Vector3.fetchTempInstance(); final Vector3 zAxis = Vector3.fetchTempInstance(); direction.normalize(zAxis); up.normalize(xAxis).crossLocal(zAxis); zAxis.cross(xAxis, yAxis); fromAxes(xAxis, yAxis, zAxis); normalizeLocal(); Vector3.releaseTempInstance(xAxis); Vector3.releaseTempInstance(yAxis); Vector3.releaseTempInstance(zAxis); return this; }
/** * Modifies this matrix to equal the rotation required to point the z-axis at 'direction' and the y-axis to 'up'. * * @param direction * where to 'look' at * @param up * a vector indicating the local up direction. * @return this matrix for chaining */ public Matrix3 lookAt(final ReadOnlyVector3 direction, final ReadOnlyVector3 up) { final Vector3 xAxis = Vector3.fetchTempInstance(); final Vector3 yAxis = Vector3.fetchTempInstance(); final Vector3 zAxis = Vector3.fetchTempInstance(); direction.normalize(zAxis); up.normalize(xAxis).crossLocal(zAxis).normalizeLocal(); zAxis.cross(xAxis, yAxis); fromAxes(xAxis, yAxis, zAxis); Vector3.releaseTempInstance(xAxis); Vector3.releaseTempInstance(yAxis); Vector3.releaseTempInstance(zAxis); return this; }
/** * Modifies this quaternion to equal the rotation required to point the z-axis at 'direction' and the y-axis to * 'up'. * * @param direction * where to 'look' at * @param up * a vector indicating the local up direction. * @return this quaternion for chaining. */ public Quaternion lookAt(final ReadOnlyVector3 direction, final ReadOnlyVector3 up) { final Vector3 xAxis = Vector3.fetchTempInstance(); final Vector3 yAxis = Vector3.fetchTempInstance(); final Vector3 zAxis = Vector3.fetchTempInstance(); direction.normalize(zAxis); up.normalize(xAxis).crossLocal(zAxis); zAxis.cross(xAxis, yAxis); fromAxes(xAxis, yAxis, zAxis); normalizeLocal(); Vector3.releaseTempInstance(xAxis); Vector3.releaseTempInstance(yAxis); Vector3.releaseTempInstance(zAxis); return this; }
@Test public void testCross() { final Vector3 vec1 = new Vector3(1, 0, 0); final Vector3 vec2 = new Vector3(0, 1, 0); assertEquals(Vector3.UNIT_Z, vec1.cross(vec2, null)); assertEquals(Vector3.UNIT_Z, vec1.cross(vec2, new Vector3())); assertEquals(Vector3.UNIT_Z, vec1.cross(0, 1, 0, null)); assertEquals(Vector3.UNIT_Z, vec1.cross(0, 1, 0, new Vector3())); vec1.crossLocal(vec2); assertEquals(Vector3.UNIT_Z, vec1); vec2.crossLocal(1, 0, 0); assertEquals(Vector3.NEG_UNIT_Z, vec2); }
_up.set(Vector3.UNIT_Y); _left.set(_up).crossLocal(_direction).normalizeLocal(); if (_left.equals(Vector3.ZERO)) { if (_direction.getX() != 0.0) { _up.set(_direction).crossLocal(_left).normalizeLocal(); onFrameChange();
_up.set(Vector3.UNIT_Y); _left.set(_up).crossLocal(_direction).normalizeLocal(); if (_left.equals(Vector3.ZERO)) { if (_direction.getX() != 0.0) { _up.set(_direction).crossLocal(_left).normalizeLocal(); onFrameChange();
public void updateLeftRightCameraFrames() { // update camera frame final Vector3 rightDir = Vector3.fetchTempInstance(); final Vector3 work = Vector3.fetchTempInstance(); rightDir.set(getDirection()).crossLocal(getUp()).multiplyLocal(_eyeSeparation / 2.0); _leftCamera.setFrame(getLocation().subtract(rightDir, work), getLeft(), getUp(), getDirection()); _rightCamera.setFrame(getLocation().add(rightDir, work), getLeft(), getUp(), getDirection()); Vector3.releaseTempInstance(work); Vector3.releaseTempInstance(rightDir); }
public void updateLeftRightCameraFrames() { // update camera frame final Vector3 rightDir = Vector3.fetchTempInstance(); final Vector3 work = Vector3.fetchTempInstance(); rightDir.set(getDirection()).crossLocal(getUp()).multiplyLocal(_eyeSeparation / 2.0); _leftCamera.setFrame(getLocation().subtract(rightDir, work), getLeft(), getUp(), getDirection()); _rightCamera.setFrame(getLocation().add(rightDir, work), getLeft(), getUp(), getDirection()); Vector3.releaseTempInstance(work); Vector3.releaseTempInstance(rightDir); }
final Vector3 edge1 = Vector3.fetchTempInstance().set(_gridTriB.getB()).subtractLocal(_gridTriB.getA()); final Vector3 edge2 = Vector3.fetchTempInstance().set(_gridTriB.getC()).subtractLocal(_gridTriB.getA()); normalStore.set(edge1).crossLocal(edge2).normalizeLocal(); final Vector3 edge1 = Vector3.fetchTempInstance().set(_gridTriA.getB()).subtractLocal(_gridTriA.getA()); final Vector3 edge2 = Vector3.fetchTempInstance().set(_gridTriA.getC()).subtractLocal(_gridTriA.getA()); normalStore.set(edge1).crossLocal(edge2).normalizeLocal();