public RawHeightMap(float heightData[]) { this.heightData = heightData; this.size = (int) FastMath.sqrt(heightData.length); this.format = FORMAT_8BIT; }
public float[] createHeightSubBlock(float[] heightMap, int x, int y, int side) { float[] rVal = new float[side * side]; int bsize = (int) FastMath.sqrt(heightMap.length); int count = 0; for (int i = y; i < side + y; i++) { for (int j = x; j < side + x; j++) { if (j < bsize && i < bsize) rVal[count] = heightMap[j + (i * bsize)]; count++; } } return rVal; }
public static float getMipFromRoughness(float roughness, int miptot) { return FastMath.sqrt(roughness) * (miptot - 1); }
/** * used to compute the solid angle * * @param x tex coordinates * @param y tex coordinates * @return */ private static float areaElement(float x, float y) { return (float) Math.atan2(x * y, sqrt(x * x + y * y + 1)); }
/** * <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)); }
/** * <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(Vector2f v) { return FastMath.sqrt(distanceSquared(v)); }
public byte getAlpha(float x, float y) { float d = FastMath.abs(FastMath.sqrt((x - center[0]) * (x - center[0]) + (y - center[1]) * (y - center[1]))); return (byte) (d >= r ? 0 : -255.0f * d / r + 255.0f); } });
public byte getAlpha(float x, float y) { float d = FastMath.abs(FastMath.sqrt((x - center[0]) * (x - center[0]) + (y - center[1]) * (y - center[1]))); return (byte) (d >= r ? 0 : 255); } });
/** * <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>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(Vector3f v) { return FastMath.sqrt(distanceSquared(v)); }
public float distance(Vector3f point) { return FastMath.sqrt(distanceSquared(point)); }
public float distance(LineSegment ls) { return FastMath.sqrt(distanceSquared(ls)); }
public float distance(Vector3f point) { return FastMath.sqrt(distanceSquared(point)); }
public float distance(Ray r) { return FastMath.sqrt(distanceSquared(r)); }
/** * Calculates the minimum bounding sphere of 2 points. Used in welzl's * algorithm. * * @param O * The 1st point inside the sphere. * @param A * The 2nd point inside the sphere. * @see #calcWelzl(java.nio.FloatBuffer) */ private void setSphere(Vector3f O, Vector3f A) { radius = FastMath.sqrt(((A.x - O.x) * (A.x - O.x) + (A.y - O.y) * (A.y - O.y) + (A.z - O.z) * (A.z - O.z)) / 4f) + RADIUS_EPSILON - 1f; center.interpolateLocal(O, A, .5f); }
protected void addLineFault(float[][] tempBuffer, Random random, float faultHeight, float range) { int x1 = random.nextInt(size); int x2 = random.nextInt(size); int y1 = random.nextInt(size); int y2 = random.nextInt(size); for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float dist = ((x2 - x1) * (j - y1) - (y2 - y1) * (i - x1)) / (FastMath.sqrt(FastMath.sqr(x2 - x1) + FastMath.sqr(y2 - y1))); tempBuffer[i][j] += calcHeight(dist, random, faultHeight, range); } } }
public static Quaternion exp(Quaternion q, Quaternion store) { float len = FastMath.sqrt(q.x * q.x + q.y * q.y + q.z * q.z); float sinLen = FastMath.sin(len); float cosLen = FastMath.cos(len); store.w = cosLen; if (len > 0) { store.x = sinLen * q.x / len; store.y = sinLen * q.y / len; store.z = sinLen * q.z / len; } else { store.x = 0; store.y = 0; store.z = 0; } return store; }