@Override public void spawnAux (Vector3 vector, float percent) { Triangle t = distribution.value(); float a = MathUtils.random(), b = MathUtils.random(); vector.set(t.x1 + a * (t.x2 - t.x1) + b * (t.x3 - t.x1), t.y1 + a * (t.y2 - t.y1) + b * (t.y3 - t.y1), t.z1 + a * (t.z2 - t.z1) + b * (t.z3 - t.z1)); }
public static boolean intersectSegmentPlane (Vector3 start, Vector3 end, Plane plane, Vector3 intersection) { Vector3 dir = v0.set(end).sub(start); float denom = dir.dot(plane.getNormal()); if (denom == 0f) return false; float t = -(start.dot(plane.getNormal()) + plane.getD()) / denom; if (t < 0 || t > 1) return false; intersection.set(start).add(dir.scl(t)); return true; }
private Vector3 getTranslation (Matrix4 worldTransform, Vector3 center, Vector3 output) { if (center.isZero()) worldTransform.getTranslation(output); else if (!worldTransform.hasRotationOrScaling()) worldTransform.getTranslation(output).add(center); else output.set(center).mul(worldTransform); return output; }
/** Sets the rotation of this decal based on the (normalized) direction and up vector. * @param dir the direction vector * @param up the up vector */ public void setRotation (Vector3 dir, Vector3 up) { tmp.set(up).crs(dir).nor(); tmp2.set(dir).crs(tmp).nor(); rotation.setFromAxes(tmp.x, tmp2.x, dir.x, tmp.y, tmp2.y, dir.y, tmp.z, tmp2.z, dir.z); updated = false; }
/** Sets the matrix to a rotation matrix around the given axis. * * @param axis The axis * @param radians The angle in radians * @return This matrix for the purpose of chaining methods together. */ public Matrix4 setToRotationRad (Vector3 axis, float radians) { if (radians == 0) { idt(); return this; } return set(quat.setFromAxisRad(axis, radians)); }
/** Set the matrix to a rotation matrix between two vectors. * @param v1 The base vector * @param v2 The target vector * @return This matrix for the purpose of chaining methods together */ public Matrix4 setToRotation (final Vector3 v1, final Vector3 v2) { return set(quat.setFromCross(v1, v2)); }
/** Rotates this vector by the given angle in degrees around the given axis. * * @param degrees the angle in degrees * @param axisX the x-component of the axis * @param axisY the y-component of the axis * @param axisZ the z-component of the axis * @return This vector for chaining */ public Vector3 rotate (float degrees, float axisX, float axisY, float axisZ) { return this.mul(tmpMat.setToRotation(axisX, axisY, axisZ, degrees)); }
/** Postmultiplies this matrix with a (counter-clockwise) rotation matrix. Postmultiplication is also used by OpenGL ES' 1.x * glTranslate/glRotate/glScale * @param axisX The x-axis component of the vector to rotate around. * @param axisY The y-axis component of the vector to rotate around. * @param axisZ The z-axis component of the vector to rotate around. * @param radians The angle in radians * @return This matrix for the purpose of chaining methods together. */ public Matrix4 rotateRad (float axisX, float axisY, float axisZ, float radians) { if (radians == 0) return this; quat.setFromAxisRad(axisX, axisY, axisZ, radians); return rotate(quat); }
/** Construct a new FloatCounter * @param windowSize The size of the mean window or 1 or below to not use a windowed mean. */ public FloatCounter (int windowSize) { mean = (windowSize > 1) ? new WindowedMean(windowSize) : null; reset(); }
public static Vector3 pick (float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, Vector3 vector) { float a = MathUtils.random(), b = MathUtils.random(); return vector.set(x1 + a * (x2 - x1) + b * (x3 - x1), y1 + a * (y2 - y1) + b * (y3 - y1), z1 + a * (z2 - z1) + b * (z3 - z1)); }
@Override public void spawnAux (Vector3 vector, float percent) { Triangle t = distribution.value(); float a = MathUtils.random(), b = MathUtils.random(); vector.set(t.x1 + a * (t.x2 - t.x1) + b * (t.x3 - t.x1), t.y1 + a * (t.y2 - t.y1) + b * (t.y3 - t.y1), t.z1 + a * (t.z2 - t.z1) + b * (t.z3 - t.z1)); }
/** Rotates this vector by the given angle in degrees around the given axis. * * @param axis the axis * @param degrees the angle in degrees * @return This vector for chaining */ public Vector3 rotate (final Vector3 axis, float degrees) { tmpMat.setToRotation(axis, degrees); return this.mul(tmpMat); }
/** Postmultiplies this matrix with a (counter-clockwise) rotation matrix. Postmultiplication is also used by OpenGL ES' 1.x * glTranslate/glRotate/glScale * @param axisX The x-axis component of the vector to rotate around. * @param axisY The y-axis component of the vector to rotate around. * @param axisZ The z-axis component of the vector to rotate around. * @param radians The angle in radians * @return This matrix for the purpose of chaining methods together. */ public Matrix4 rotateRad (float axisX, float axisY, float axisZ, float radians) { if (radians == 0) return this; quat.setFromAxisRad(axisX, axisY, axisZ, radians); return rotate(quat); }