congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
Vector4.normalizeLocal
Code IndexAdd Tabnine 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)

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

  • Parsing JSON documents to java classes using gson
  • requestLocationUpdates (LocationManager)
  • getContentResolver (Context)
  • getExternalFilesDir (Context)
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • String (java.lang)
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now