Random spline stuff added.

Originally committed to SVN as r1371.
This commit is contained in:
Rodrigo Braz Monteiro 2007-07-05 14:30:28 +00:00
parent 28b7264d3b
commit 0bc8847f7a
2 changed files with 33 additions and 0 deletions

View File

@ -47,6 +47,28 @@ SplineCurve::SplineCurve() {
}
/////////////////////////////////////////////////////////
// Split a curve in two using the de Casteljau algorithm
void SplineCurve::Split(SplineCurve &c1,SplineCurve &c2,float t) {
// Split a line
if (type == CURVE_LINE) {
c1.type = CURVE_LINE;
c2.type = CURVE_LINE;
c1.p1 = p1;
c1.p2 = p1*t+p2*(1-t);
c2.p1 = c1.p2;
c2.p2 = p2;
}
// Split a bicubic
else if (type == CURVE_BICUBIC) {
c1.type = CURVE_BICUBIC;
c2.type = CURVE_BICUBIC;
// TODO
}
}
//////////////////////
// Spline constructor
Spline::Spline() {
@ -301,9 +323,17 @@ void Spline::GetPointList(std::vector<Vector2D> &points) {
}
///////////////////////////////////////////////////////
// t value and curve of the point closest to reference
void GetClosestParametricPoint(Vector2D reference,int &curve,float &t) {
// TODO
}
//////////////////////////////
// Point closest to reference
Vector2D Spline::GetClosestPoint(Vector2D reference) {
// TODO
return Vector2D(-1,-1);
}
@ -311,5 +341,6 @@ Vector2D Spline::GetClosestPoint(Vector2D reference) {
//////////////////////////////////////
// Control point closest to reference
Vector2D Spline::GetClosestControlPoint(Vector2D reference) {
// TODO
return Vector2D(-1,-1);
}

View File

@ -63,6 +63,7 @@ public:
CurveType type;
SplineCurve();
void Split(SplineCurve &c1,SplineCurve &c2,float t=0.5);
};
@ -82,6 +83,7 @@ public:
void GetPointList(std::vector<Vector2D> &points);
void GetClosestParametricPoint(Vector2D reference,int &curve,float &t);
Vector2D GetClosestPoint(Vector2D reference);
Vector2D GetClosestControlPoint(Vector2D reference);
};