public void multLocal(Quaternion rotation) { Vector3f axis = new Vector3f(); float angle = rotation.toAngleAxis(axis); Matrix4f matrix4f = new Matrix4f(); matrix4f.fromAngleAxis(angle, axis); multLocal(matrix4f); }
private boolean insidePlane(Plane p, Vector3f axis1, Vector3f axis2, Vector3f axis3, Vector3f tn) { // transform the plane normal in the box local space. tn.set(axis1.dot(p.getNormal()), axis2.dot(p.getNormal()), axis3.dot(p.getNormal())); // distance check float radius = FastMath.abs(tn.x) + FastMath.abs(tn.y) + FastMath.abs(tn.z); float distance = p.pseudoDistance(transform.getTranslation()); if (distance < -radius) { return false; } return true; }
private static Quaternion spline(Quaternion qnm1, Quaternion qn, Quaternion qnp1, Quaternion store, Quaternion tmp) { Quaternion invQn = new Quaternion(-qn.x, -qn.y, -qn.z, qn.w); log(invQn.mult(qnp1), tmp); log(invQn.mult(qnm1), store); store.addLocal(tmp).multLocal(-1f / 4f); exp(store, tmp); store.set(qn).multLocal(tmp); return store.normalizeLocal(); //return qn * (((qni * qnm1).log() + (qni * qnp1).log()) / -4).exp(); }
public static boolean equalsEpsilon(Quaternion q1, Quaternion q2) { return (FastMath.abs(q1.getX() - q2.getX()) < epsilon && FastMath.abs(q1.getY() - q2.getY()) < epsilon && FastMath.abs(q1.getZ() - q2.getZ()) < epsilon && FastMath.abs(q1.getW() - q2.getW()) < epsilon) || (FastMath.abs(q1.getX() + q2.getX()) < epsilon && FastMath.abs(q1.getY() + q2.getY()) < epsilon && FastMath.abs(q1.getZ() + q2.getZ()) < epsilon && FastMath.abs(q1.getW() + q2.getW()) < epsilon); }
@Override protected void applyVelocityVariation(Particle particle) { temp.set(FastMath.nextRandomFloat() * velocityVariation, FastMath.nextRandomFloat() * velocityVariation, FastMath.nextRandomFloat() * velocityVariation); particle.velocity.addLocal(temp); }
public void set(LineSegment ls) { this.origin = new Vector3f(ls.getOrigin()); this.direction = new Vector3f(ls.getDirection()); this.extent = ls.getExtent(); }
/** * Retreives the scale vector from the matrix. * * @return the scale vector */ public Vector3f toScaleVector() { Vector3f result = new Vector3f(); this.toScaleVector(result); return result; }
void set(float x, float y, float z) { float[] a = {x, y, z}; rotation.fromAngles(a); eulerAngles.set(x, y, z); } }
private static void toTangentsWithParity(IrVertex vertex) { if (vertex.tang != null && vertex.bitang != null) { float wCoord = vertex.norm.cross(vertex.tang).dot(vertex.bitang) < 0f ? -1f : 1f; vertex.tang4d = new Vector4f(vertex.tang.x, vertex.tang.y, vertex.tang.z, wCoord); vertex.tang = null; vertex.bitang = null; } }
public Transform invert() { Transform t = new Transform(); t.fromTransformMatrix(toTransformMatrix().invertLocal()); return t; }
/** * <code>angleBetween</code> returns (in radians) the angle between two vectors. * It is assumed that both this vector and the given vector are unit vectors (iow, normalized). * * @param otherVector a unit vector to find the angle against * @return the angle in radians. */ public float angleBetween(Vector3f otherVector) { float dotProduct = dot(otherVector); float angle = FastMath.acos(dotProduct); return angle; }
/** * <code>distance</code> calculates the distance between this vector and * vector v. * * @param v the second vector to determine the distance. * @return the distance between the two vectors. */ public float distance(Vector2f v) { return FastMath.sqrt(distanceSquared(v)); }
/** * <code>length</code> calculates the magnitude of this vector. * * @return the length or magnitude of the vector. */ public float length() { return FastMath.sqrt(lengthSquared()); }
/** * <code>distance</code> calculates the distance between this vector and * vector v. * * @param v the second vector to determine the distance. * @return the distance between the two vectors. */ public float distance(Vector4f v) { return FastMath.sqrt(distanceSquared(v)); }
/** * Initialize this plane using the three points of the given triangle. * * @param t * the triangle */ public void setPlanePoints(AbstractTriangle t) { setPlanePoints(t.get1(), t.get2(), t.get3()); }