added curveFitter and hermite stuff

This commit is contained in:
Dave Schuyler 2001-01-17 01:46:41 +00:00
parent cb9c0434d5
commit 2afad32dd2

View File

@ -18,6 +18,7 @@
#include "curve.h"
#include "config_parametrics.h"
#include "hermiteCurve.h"
#include "nurbsCurve.h"
#include "curveDrawer.h"
@ -270,7 +271,6 @@ compute_t(double start_t, double length_offset, double guess,
////////////////////////////////////////////////////////////////////
bool ParametricCurve::
convert_to_hermite(HermiteCurve &hc) const {
#if 0 //[////todo:skyler
BezierSegs bz_segs;
if (!GetBezierSegs(bz_segs)) {
return false;
@ -293,7 +293,7 @@ convert_to_hermite(HermiteCurve &hc) const {
scale_in = scale_out;
scale_out = bz_segs[i+1]._t - bz_segs[i]._t;
if (!bz_segs[i]._v[3].almostEqual(bz_segs[i+1]._v[0], 0.0001)) {
if (!bz_segs[i]._v[3].almost_equal(bz_segs[i+1]._v[0], 0.0001)) {
// Oops, we have a cut.
hc.set_cv_type(n, HC_CUT);
}
@ -317,21 +317,20 @@ convert_to_hermite(HermiteCurve &hc) const {
int num_cvs = hc.get_num_cvs();
for (n = 1; n < num_cvs-1; n++) {
if (hc.get_cv_type(n)!=HC_CUT) {
pfVec3 in = hc.get_cv_in(n);
pfVec3 out = hc.get_cv_out(n);
LVector3f in = hc.get_cv_in(n);
LVector3f out = hc.get_cv_out(n);
if (in.almostEqual(out, 0.0001)) {
if (in.almost_equal(out, 0.0001)) {
hc.set_cv_type(n, HC_SMOOTH);
} else {
in.normalize();
out.normalize();
if (in.almostEqual(out, 0.0001)) {
if (in.almost_equal(out, 0.0001)) {
hc.set_cv_type(n, HC_G1);
}
}
}
}
#endif //]
return true;
}
@ -1244,6 +1243,36 @@ get_2ndtangent(double t, LVector3f &tangent2) const {
}
////////////////////////////////////////////////////////////////////
// Function: CubicCurveseg::hermite_basis
// Access: Public
// Description: Defines the curve segment as a Hermite. This only
// sets up the basis vectors, so the curve will be
// computed correctly; it does not retain the CV's.
////////////////////////////////////////////////////////////////////
void CubicCurveseg::
hermite_basis(const HermiteCurveCV &cv0,
const HermiteCurveCV &cv1,
double tlength) {
static LMatrix4f
Mh(2, -3, 0, 1,
-2, 3, 0, 0,
1, -2, 1, 0,
1, -1, 0, 0);
LVector4f Gx(cv0._p[0], cv1._p[0],
cv0._out[0]*tlength, cv1._in[0]*tlength);
LVector4f Gy(cv0._p[1], cv1._p[1],
cv0._out[1]*tlength, cv1._in[1]*tlength);
LVector4f Gz(cv0._p[2], cv1._p[2],
cv0._out[2]*tlength, cv1._in[2]*tlength);
Bx = Gx * Mh;
By = Gy * Mh;
Bz = Gz * Mh;
rational = false;
}
////////////////////////////////////////////////////////////////////
// Function: CubicCurveseg::bezier_basis
// Access: Public