|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||

java.lang.Objectorg.jcurl.math.ShaperUtils
public abstract class ShaperUtils
Helper for convenient approximated Java2D drawing of arbitratry
R1RNFunctions with at least 2 dimensions.
Shaper,
Shapeable| Constructor Summary | |
|---|---|
ShaperUtils()
|
|
| Method Summary | |
|---|---|
(package private) static void |
curveTo(R1RNFunction f,
double tmin,
double tmax,
GeneralPath gp,
float zoom)
Compute the control points and add one Cubic Bezier Curve to a GeneralPath. |
static Shape |
interpolateCubic(R1RNFunction src,
double min,
double max,
int curves,
float zoom,
Interpolator ip)
Interpolate using Cubic Bezier Curves. |
static Shape |
interpolateLinear(R1RNFunction src,
double min,
double max,
int curves,
float zoom,
Interpolator ip)
Interpolate using Linear Bezier Curves. |
static Shape |
interpolateQuadratic(R1RNFunction src,
double min,
double max,
int curves,
float zoom,
Interpolator ip)
Interpolate using Quadratic Bezier Curves. |
(package private) static void |
lineTo(R1RNFunction f,
double tmax,
GeneralPath gp,
float zoom)
Add one Linear Bezier Curve to a GeneralPath. |
(package private) static void |
quadTo(R1RNFunction f,
double tmin,
double tmax,
GeneralPath gp,
float zoom)
Compute the control point and add one Quadratic Bezier Curve to a GeneralPath. |
(package private) static String |
toString(double[] arr)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ShaperUtils()
| Method Detail |
|---|
static void curveTo(R1RNFunction f,
double tmin,
double tmax,
GeneralPath gp,
float zoom)
GeneralPath. Does no initial
GeneralPath.moveTo(float, float).
This ansatz uses no adaptive optimisation but the nature of curves as they're typical to curling:
This causes quite a computation - without iteration/recursion though, but
1 square root and many double multiplications - but this is well worth
while as we can reduce the curve segments to draw significantly. One
cubic bezier curve per seven meters curve length gives an error < 2 mm
(using CurlerDenny with 24s draw-to-tee and 1m curl)!
TODO maybe re-use endpoint location and velocity. This can cause pain at C1 discontinuous t's (collissions).
radsubstflag: true$
k1_0 = k0_0 + l * v0_0;
k1_1 = k0_1 + l * v0_1;
k2_0 = k3_0 - n * v3_0;
k2_1 = k3_1 - n * v3_1;
l/n=a/c;
((k2_0 - k1_0)*(k2_0 - k1_0) + (k2_1 - k1_1)*(k2_1 - k1_1)) / (n*n) = b*b / (c*c);
solve([%th(6), %th(5), %th(4), %th(3), %th(2), %th(1)],[k1_0, k1_1, k2_0, k2_1, l, n]);
factor(%);
ratsimp(%);
ratsubst(V0, v0_1ˆ2+v0_0ˆ2, %);
ratsubst(V3, v3_1ˆ2+v3_0ˆ2, %);
ratsubst(A, k0_1-k3_1, %);
ratsubst(B, k0_0-k3_0, %);
ratsubst(T, 2*a*c*v0_0*v3_0+aˆ2*v0_1ˆ2+aˆ2*v0_0ˆ2-bˆ2, %);
ratsubst(Q, cˆ2*V3+aˆ2*V0+T+2*a*c*v0_1*v3_1-aˆ2*v0_1ˆ2-aˆ2*v0_0ˆ2, %);
ratsubst(W, Bˆ2*T+Bˆ2*(bˆ2-Q)+cˆ2*(v3_0ˆ2*Bˆ2-v3_0ˆ2*Aˆ2)-aˆ2*v0_1ˆ2*Bˆ2+v3_1*(2*cˆ2*v3_0*A*B
+2*a*c*v0_0*A*B)+v0_1*(2*a*c*v3_0*A*B+2*aˆ2*v0_0*A*B)-2*a*c*v0_0*v3_0*Aˆ2-aˆ2*v0_0ˆ2*Aˆ2
+bˆ2*Aˆ2, %);
expand(%);
factor(%);
ratsubst(R, c*v3_0*B+a*v0_0*B+c*v3_1*A+a*v0_1*A, %);
public static Shape interpolateCubic(R1RNFunction src,
double min,
double max,
int curves,
float zoom,
Interpolator ip)
Computes the required intermediate t samples and delegates
to curveTo(R1RNFunction, double, double, GeneralPath, float) to
compute the interpolating curve segments.
src - the (at least 2-dimensional) curve. Higher dimensions are
ignored.min - the min input t to
R1RNFunction.at(double, int, int)max - the max input t to
R1RNFunction.at(double, int, int)curves - the number of interpolating cubic bezier curves - must be
>= 1.zoom - graphics zoom factor (typically 1)ip - the Interpolator to get the intermediate
t sample values.curveTo(R1RNFunction, double, double, GeneralPath, float)
public static Shape interpolateLinear(R1RNFunction src,
double min,
double max,
int curves,
float zoom,
Interpolator ip)
Computes the required intermediate t samples and delegates
to lineTo(R1RNFunction, double, GeneralPath, float) to compute
the interpolating curve segments.
src - the (at least 2-dimensional) curve. Higher dimensions are
ignored.min - the min input t to
R1RNFunction.at(double, int, int)max - the max input t to
R1RNFunction.at(double, int, int)curves - the number of line segments - must be >= 1.zoom - graphics zoom factor (typically 1)ip - the Interpolator to get the intermediate sample
t values.lineTo(R1RNFunction, double, GeneralPath, float)
public static Shape interpolateQuadratic(R1RNFunction src,
double min,
double max,
int curves,
float zoom,
Interpolator ip)
Computes the required intermediate t samples and delegates
to quadTo(R1RNFunction, double, double, GeneralPath, float) to
compute the interpolating curve segments.
src - the (2-dimensional) curve. Higher dimensions are ignored.min - the min input t to
R1RNFunction.at(double, int, int)max - the max input t to
R1RNFunction.at(double, int, int)curves - the number of line segments - must be >= 1.zoom - graphics zoom factor (typically 1)ip - the Interpolator to get the intermediate sample
t values.quadTo(R1RNFunction, double, double, GeneralPath, float)
static final void lineTo(R1RNFunction f,
double tmax,
GeneralPath gp,
float zoom)
GeneralPath. Does no initial
GeneralPath.moveTo(float, float).
Just connect start- and endpoint.
TODO maybe re-use endpoint location and velocity. This can cause pain at C1 discontinuous t's (collissions).
static final void quadTo(R1RNFunction f,
double tmin,
double tmax,
GeneralPath gp,
float zoom)
GeneralPath. Does no initial
GeneralPath.moveTo(float, float).
This ansatz uses no adaptive optimisation but only
TODO maybe re-use endpoint location and velocity. This can cause pain at C1 discontinuous t's (collissions).
radsubstflag: true$ k0_0 + l * v0_0 = k2_0 + m * v2_0; k0_1 + l * v0_1 = k2_1 + m * v2_1; solve([%th(2),%th(1)],[l,m]); subst(q, v0_1 * v2_0 - v0_0 * v2_1, %); subst(dx_0 + k0_0, k2_0, %); subst(dx_1 + k0_1, k2_1, %); ratsimp(%);
static String toString(double[] arr)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||