From: <ma...@us...> - 2003-05-22 07:36:30
|
Update of /cvsroot/jrman/drafts/src/org/jrman/util In directory sc8-pr-cvs1:/tmp/cvs-serv23650/src/org/jrman/util Modified Files: Calc.java Log Message: Started work on bicubic patches. Index: Calc.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/util/Calc.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Calc.java 3 May 2003 18:02:48 -0000 1.7 --- Calc.java 22 May 2003 07:36:27 -0000 1.8 *************** *** 33,45 **** private Calc() { } ! public static int clamp(int v, int min, int max) { return Math.min(Math.max(v, min), max); } ! public static float log(float x, float base) { return (float) (Math.log(x) / Math.log(base)); } ! public static float sign(float x) { if (x < 0) --- 33,45 ---- private Calc() { } ! public static int clamp(int v, int min, int max) { return Math.min(Math.max(v, min), max); } ! public static float log(float x, float base) { return (float) (Math.log(x) / Math.log(base)); } ! public static float sign(float x) { if (x < 0) *************** *** 49,53 **** return 0f; } ! public static float step(float min, float value) { if (value < min) --- 49,53 ---- return 0f; } ! public static float step(float min, float value) { if (value < min) *************** *** 55,59 **** return 1f; } ! public static float smoothstep(float min, float max, float value) { if (value < min) --- 55,59 ---- return 1f; } ! public static float smoothstep(float min, float max, float value) { if (value < min) *************** *** 61,82 **** if (value >= max) return 1f; ! value = ( value - min) / (max - min); return value * value * (3 - 2 * value); } ! public static float clamp(float v, float min, float max) { return Math.min(Math.max(v, min), max); } ! ! public static float depth(Point3f p, Transform toCamera, float near, float far, Point3f tmp) { ! toCamera.transformPoint(p, tmp); ! return (tmp.z - near) / (far - near); } ! public static float depth(Point3f p, Transform toCamera, float near, float far) { Point3f tmp = new Point3f(); return depth(p, toCamera, near, far, tmp); } ! public static void perp(Tuple2f t, Tuple2f out) { out.set(-t.y, t.x); --- 61,87 ---- if (value >= max) return 1f; ! value = (value - min) / (max - min); return value * value * (3 - 2 * value); } ! public static float clamp(float v, float min, float max) { return Math.min(Math.max(v, min), max); } ! ! public static float depth( ! Point3f p, ! Transform toCamera, ! float near, ! float far, ! Point3f tmp) { ! toCamera.transformPoint(p, tmp); ! return (tmp.z - near) / (far - near); } ! public static float depth(Point3f p, Transform toCamera, float near, float far) { Point3f tmp = new Point3f(); return depth(p, toCamera, near, far, tmp); } ! public static void perp(Tuple2f t, Tuple2f out) { out.set(-t.y, t.x); *************** *** 208,212 **** alphaV); } ! public static float fovToFocalLength(float fov) { return (float) (1 / Math.tan(Math.toRadians(fov / 2))); --- 213,292 ---- alphaV); } ! ! public static float bezierInterpolate(float p1, float p2, float p3, float p4, float u) { ! float oneMinusU = 1f - u; ! return oneMinusU * oneMinusU * oneMinusU * p1 ! + 3f * u * oneMinusU * oneMinusU * p2 ! + 3f * u * u * oneMinusU * p3 ! + u * u * u * p4; ! } ! ! public static float bezierInterpolate( ! float p00, ! float p10, ! float p20, ! float p30, ! float p01, ! float p11, ! float p21, ! float p31, ! float p02, ! float p12, ! float p22, ! float p32, ! float p03, ! float p13, ! float p23, ! float p33, ! float u, ! float v) { ! return bezierInterpolate( ! bezierInterpolate(p00, p10, p20, p30, u), ! bezierInterpolate(p01, p11, p21, p31, u), ! bezierInterpolate(p02, p12, p22, p32, u), ! bezierInterpolate(p03, p13, p23, p33, u), ! v); ! } ! ! public static Point3f bezierInterpolate( ! Point3f p1, ! Point3f p2, ! Point3f p3, ! Point3f p4, ! float u) { ! Point3f result = new Point3f(); ! result.x = bezierInterpolate(p1.x, p2.x, p3.x, p4.x, u); ! result.y = bezierInterpolate(p1.y, p2.y, p3.y, p4.y, u); ! result.z = bezierInterpolate(p1.z, p2.z, p3.z, p4.z, u); ! return result; ! } ! ! public static Point3f bezierInterpolate( ! Point3f p00, ! Point3f p10, ! Point3f p20, ! Point3f p30, ! Point3f p01, ! Point3f p11, ! Point3f p21, ! Point3f p31, ! Point3f p02, ! Point3f p12, ! Point3f p22, ! Point3f p32, ! Point3f p03, ! Point3f p13, ! Point3f p23, ! Point3f p33, ! float u, ! float v) { ! return bezierInterpolate( ! bezierInterpolate(p00, p10, p20, p30, u), ! bezierInterpolate(p01, p11, p21, p31, u), ! bezierInterpolate(p02, p12, p22, p32, u), ! bezierInterpolate(p03, p13, p23, p33, u), ! v); ! } ! public static float fovToFocalLength(float fov) { return (float) (1 / Math.tan(Math.toRadians(fov / 2))); |