From 0bc8847f7a2e9333c89878f21a256849e0ed8feb Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Thu, 5 Jul 2007 14:30:28 +0000 Subject: [PATCH] Random spline stuff added. Originally committed to SVN as r1371. --- aegisub/spline.cpp | 31 +++++++++++++++++++++++++++++++ aegisub/spline.h | 2 ++ 2 files changed, 33 insertions(+) diff --git a/aegisub/spline.cpp b/aegisub/spline.cpp index cdb4aef84..78594ffd9 100644 --- a/aegisub/spline.cpp +++ b/aegisub/spline.cpp @@ -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 &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); } diff --git a/aegisub/spline.h b/aegisub/spline.h index a4b326cef..702599775 100644 --- a/aegisub/spline.h +++ b/aegisub/spline.h @@ -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 &points); + void GetClosestParametricPoint(Vector2D reference,int &curve,float &t); Vector2D GetClosestPoint(Vector2D reference); Vector2D GetClosestControlPoint(Vector2D reference); };