Package javax.vecmath

Examples of javax.vecmath.Vector3f.normalize()


            v1.sub(b, a);
            v2.sub(c, a);
            faceNormal.cross(v1, v2);
            if (faceNormal.length()==0) continue;
            faceNormal.normalize();

            // suppose the faces are nearly flat, with small deflection
            // check the scalar product is >0, so each face is the same orientation
            // otherwise, reverse the normal
            float scalara = normal[ja] * faceNormal.x + normal[ja+1] * faceNormal.y + normal[ja+2] * faceNormal.z;
 
View Full Code Here


    float fov = 2f * (float) Math.atan(tanFov);

    Vector3f rayFrom = new Vector3f(getCameraPosition());
    Vector3f rayForward = new Vector3f();
    rayForward.sub(getCameraTargetPosition(), getCameraPosition());
    rayForward.normalize();
    float farPlane = 10000f;
    rayForward.scale(farPlane);

    Vector3f rightOffset = new Vector3f();
    Vector3f vertical = new Vector3f(cameraUp);
View Full Code Here

    Vector3f vertical = new Vector3f(cameraUp);

    Vector3f hor = new Vector3f();
    // TODO: check: hor = rayForward.cross(vertical);
    hor.cross(rayForward, vertical);
    hor.normalize();
    // TODO: check: vertical = hor.cross(rayForward);
    vertical.cross(hor, rayForward);
    vertical.normalize();

    float tanfov = (float) Math.tan(0.5f * fov);
 
View Full Code Here

            // plane(<point1>,<point2>,false)
            pt3 = new Point3f(pt1);
            pt3.add(pt2);
            pt3.scale(0.5f);
            norm.sub(pt1);
            norm.normalize();
          } else {
            // plane(<point1>,<vLine>,true)
          }
          return addX(Measure.getPlaneThroughPoint(pt3, norm));
        }
View Full Code Here

    float d2 = v2.length();
    // rooted finger --> zoom (at this position, perhaps?)
    if (d1 < 3 || d2 < 3)
      return;
    v1.normalize();
    v2.normalize();
    float cos12 = (v1.dot(v2));
    // cos12 > 0.8 (same direction) will be required to indicate drag
    // cos12 < -0.8 (opposite directions) will be required to indicate zoom or rotate
    if (cos12 > 0.8) {
      // two co-aligned motions
View Full Code Here

    float d12 = loc11.getDistance(loc21);
    if (d1 < 2 && d2 < 2)
      return false;
    Vector3f v00 = loc10.getVector(loc20);
    float d00 = v00.length();
    v00.normalize();
    switch (_myType) {
    case ActionManagerMT.ROTATE_GESTURE:
      _offsetCentroid = Location.getCenter(loc10, loc20);
      Vector3f v1;
      Vector3f v2;
View Full Code Here

          a = va.length();
          b = vb.length();
          c = vc.length();
          va.normalize();
          vb.normalize();
          vc.normalize();
          alpha = (float) (Math.acos(vb.dot(vc)) * 180 / Math.PI);
          beta = (float) (Math.acos(va.dot(vc)) * 180 / Math.PI);
          gamma = (float) (Math.acos(va.dot(vb)) * 180 / Math.PI);
        } else if ("positions".equals(name)) {
          parent.setUnitCell(a, b, c, alpha, beta, gamma);
View Full Code Here

      return n;
    }
    Vector3f va_prime_d = new Vector3f();
    va_prime_d.cross(vab, n);
    if (va_prime_d.dot(va_prime_d) != 0)
      va_prime_d.normalize();
    Vector3f vda = new Vector3f();
    Vector3f vcb = new Vector3f(n);
    if (v_dot_n == 0)
      v_dot_n = Float.MIN_VALUE; // allow for perpendicular axis to vab
    vcb.scale(v_dot_n);
View Full Code Here

      return;
    }
    if (plane != null) {
      // ax + by + cz + d = 0
      Vector3f norm = new Vector3f(plane.x, plane.y, plane.z);
      norm.normalize();
      float d = (float) Math.sqrt(plane.x * plane.x + plane.y * plane.y
          + plane.z * plane.z);
      for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) {
        float twoD = -Measure.distanceToPlane(plane, d, atoms[i]) * 2;
        float x = norm.x * twoD;
 
View Full Code Here

      }
    if (dx != 0) {
      Vector3f v = new Vector3f(atom);
      v.sub(atoms[atom.getBondedAtomIndex(0)]);
      float d = v.length();
      v.normalize();
      v.scale(dx - d);
      setAtomCoordRelative(atomIndex, v.x, v.y, v.z);
    }

    BitSet bsA = BitSetUtil.setBit(atomIndex);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.