static final boolean normalize(Vector3f v) { float len = v.length(); if (len > 0) { len = 1.0f/len; v.x *= len; v.y *= len; v.z *= len; return true; } return false; }
/** * Returns the angle in radians between this vector and the vector * parameter; the return value is constrained to the range [0,PI]. * @param v1 the other vector * @return the angle in radians in the range [0,PI] */ public final float angle(Vector3f v1) { double vDot = this.dot(v1) / ( this.length()*v1.length() ); if( vDot < -1.0) vDot = -1.0; if( vDot > 1.0) vDot = 1.0; return((float) (Math.acos( vDot ))); }
static boolean getNormal(Point3f p1, Point3f p2, Point3f p3, Vector3f normal) { Vector3f v1 = new Vector3f(); Vector3f v2 = new Vector3f(); // Must compute normal v1.sub(p2, p1); v2.sub(p2, p3); normal.cross(v1, v2); normal.negate(); float length = normal.length(); if (length > 0) { length = 1 / length; normal.x *= length; normal.y *= length; normal.z *= length; return true; } return false; }
float distance=2*seperationVector.length();