Codota Logo
Vector4.normalizeLocal
Code IndexAdd Codota to your IDE (free)

How to use
normalizeLocal
method
in
com.ardor3d.math.Vector4

Best Java code snippets using com.ardor3d.math.Vector4.normalizeLocal (Showing top 5 results out of 315)

  • Common ways to obtain Vector4
private void myMethod () {
Vector4 v =
  • Codota Iconnew Vector4()
  • Codota IconVector4.fetchTempInstance()
  • Codota IconReadOnlyVector4 src;new Vector4(src)
  • Smart code suggestions by Codota
}
origin: com.ardor3d/ardor3d-core

/**
 * Normalize a Vector4 in-buffer.
 * 
 * @param buf
 *            the buffer to find the Vector4 within
 * @param index
 *            the position (in terms of vectors, not floats) of the vector to normalize
 */
public static void normalizeVector4(final FloatBuffer buf, final int index) {
  final Vector4 temp = Vector4.fetchTempInstance();
  populateFromBuffer(temp, buf, index);
  temp.normalizeLocal();
  setInBuffer(temp, buf, index);
  Vector4.releaseTempInstance(temp);
}
origin: Renanse/Ardor3D

/**
 * Normalize a Vector4 in-buffer.
 * 
 * @param buf
 *            the buffer to find the Vector4 within
 * @param index
 *            the position (in terms of vectors, not floats) of the vector to normalize
 */
public static void normalizeVector4(final FloatBuffer buf, final int index) {
  final Vector4 temp = Vector4.fetchTempInstance();
  populateFromBuffer(temp, buf, index);
  temp.normalizeLocal();
  setInBuffer(temp, buf, index);
  Vector4.releaseTempInstance(temp);
}
origin: com.ardor3d/ardor3d-effects

private void calculateIntersection(final double planeHeight, final ReadOnlyVector2 screenPosition,
    final ReadOnlyMatrix4 modelViewProjectionInverseMatrix) {
  origin.set(screenPosition.getX() * 2 - 1, screenPosition.getY() * 2 - 1, -1, 1);
  direction.set(screenPosition.getX() * 2 - 1, screenPosition.getY() * 2 - 1, 1, 1);
  modelViewProjectionInverseMatrix.applyPre(origin, origin);
  modelViewProjectionInverseMatrix.applyPre(direction, direction);
  direction.subtractLocal(origin);
  // final double t = (planeHeight * origin.getW() - origin.getY())
  // / (direction.getY() - planeHeight * direction.getW());
  if (Math.abs(direction.getY()) > MathUtils.EPSILON) {
    final double t = (planeHeight - origin.getY()) / direction.getY();
    direction.multiplyLocal(t);
  } else {
    direction.normalizeLocal();
    direction.multiplyLocal(mainCamera.getFrustumFar());
  }
  origin.addLocal(direction);
}
origin: Renanse/Ardor3D

private void calculateIntersection(final double planeHeight, final ReadOnlyVector2 screenPosition,
    final ReadOnlyMatrix4 modelViewProjectionInverseMatrix) {
  origin.set(screenPosition.getX() * 2 - 1, screenPosition.getY() * 2 - 1, -1, 1);
  direction.set(screenPosition.getX() * 2 - 1, screenPosition.getY() * 2 - 1, 1, 1);
  modelViewProjectionInverseMatrix.applyPre(origin, origin);
  modelViewProjectionInverseMatrix.applyPre(direction, direction);
  direction.subtractLocal(origin);
  // final double t = (planeHeight * origin.getW() - origin.getY())
  // / (direction.getY() - planeHeight * direction.getW());
  if (Math.abs(direction.getY()) > MathUtils.EPSILON) {
    final double t = (planeHeight - origin.getY()) / direction.getY();
    direction.multiplyLocal(t);
  } else {
    direction.normalizeLocal();
    direction.multiplyLocal(mainCamera.getFrustumFar());
  }
  origin.addLocal(direction);
}
origin: Renanse/Ardor3D

@Test
public void testNormalize() {
  final Vector4 vec1 = new Vector4(2, 1, 3, -1);
  assertTrue(vec1.length() == Math.sqrt(15));
  final Vector4 vec2 = vec1.normalize(null);
  final double invLength = MathUtils.inverseSqrt(2 * 2 + 1 * 1 + 3 * 3 + -1 * -1);
  assertEquals(new Vector4(2 * invLength, 1 * invLength, 3 * invLength, -1 * invLength), vec2);
  vec1.normalizeLocal();
  assertEquals(new Vector4(2 * invLength, 1 * invLength, 3 * invLength, -1 * invLength), vec1);
  vec1.zero();
  vec1.normalize(vec2);
  assertEquals(vec1, vec2);
  // ensure no exception thrown
  vec1.normalizeLocal();
  vec1.normalize(null);
}
com.ardor3d.mathVector4normalizeLocal

Javadoc

Converts this vector into a unit vector by dividing it internally by its length. If the length is 0, (ie, if the vector is 0, 0, 0, 0) then no action is taken.

Popular methods of Vector4

  • <init>
    Constructs a new vector set to the (x, y, z, w) values of the given source vector.
  • set
    Sets the value of this vector to the (x, y, z, w) values of the provided source vector.
  • getW
  • getX
  • getY
  • getZ
  • addLocal
    Increments the values of this vector with the x, y, z and w values of the given vector.
  • getXf
  • getYf
  • getZf
  • multiplyLocal
    Internally modifies the values of this vector by multiplying them each by the given scale values.
  • setW
    Sets the fourth component of this vector to the given double value.
  • multiplyLocal,
  • setW,
  • setX,
  • setY,
  • setZ,
  • dot,
  • fetchTempInstance,
  • getWf,
  • multiply

Popular in Java

  • Reading from database using SQL prepared statement
  • getSharedPreferences (Context)
  • setRequestProperty (URLConnection)
    Sets the general request property. If a property with the key already exists, overwrite its value wi
  • runOnUiThread (Activity)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • String (java.lang)
  • Path (java.nio.file)
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now