Core 1.0
|
Cubic curves. More...
#include <curve.h>
Public Member Functions | |
CubicCurve () | |
Empty. | |
CubicCurve (const Cubic &, const Cubic &, const Cubic &) | |
Creates a cubic curve. More... | |
~CubicCurve () | |
Empty. | |
Cubic & | operator[] (int) |
Access curve components. | |
Cubic | operator[] (int) const |
Access curve components. | |
CubicCurve | operator+ () const |
Overloaded out of consistency. | |
CubicCurve | operator- () const |
Negative curve unary operator. | |
QuadricCurve | Tangent () const |
Computes the quadric curve whose components are defined as the derivative of the cubic coordinates of the curve. More... | |
Vector | Tangent (const double &) const |
Computes the tangent to the cubic curve at a given position on the curve. More... | |
Vector | Normal (const double &) const |
Computes the normal vector to the cubic curve at a given position on the curve. More... | |
double | Curvature (const double &) const |
Computes the 3D curvature to the curve at t. More... | |
double | S (const double &, int=256) const |
Compute the curvilign absisca of a point on the curve. More... | |
double | U (const double &, int=256) const |
Compute the parameter corresponding to the argument curvilign absisca of a point on the curve. More... | |
double | Length (int=256) const |
Computes the length of the cubic curve. Integration is performed over interval [0,1]. More... | |
double | Length (const double &, const double &, int=256) const |
Computes the length of the cubic curve over interval [a,b]. More... | |
double | InverseArcLength (const double &, int=256) const |
Compute the parameter t corresponding to a given input arc length. More... | |
Vector | operator() (const double &) const |
Evaluates curve point at a given location. More... | |
Vector | Eval (const double &) const |
Evaluates curve point at a given location. More... | |
Box | GetBox () const |
Compute the bounding box of the cubic curve with parameter interval [0,1]. More... | |
double | R (const Vector &, double &) const |
Returns the squared distance between a point and the cubic curve. More... | |
Matrix | GetMatrix (const double &) const |
Compute the Frenet vectors at a given point on the curve. More... | |
Frame | GetFrame (const double &) const |
Compute the Frenet frame at a given point on the curve. More... | |
Vector | BezierControl (int) const |
Compute the i-th Bézier control point of the curve. More... | |
void | Approximate (QuadricCurve &, QuadricCurve &, const double &=0.5) const |
Approximate a cubic curve by two quadric curves. More... | |
Static Public Member Functions | |
static CubicCurve | Hermite (const Vector &, const Vector &, const Vector &, const Vector &) |
Creates an Hermite cubic curve on interval [0,1] given vertex locations and tangent vectors (in that order). More... | |
static CubicCurve | Bezier (const Vector &, const Vector &, const Vector &, const Vector &) |
Creates a Bezier cubic curve on interval [0,1] given four vertex locations. More... | |
Protected Attributes | |
Cubic | z |
Cubic polynomial functions for every coordinate. | |
Friends | |
std::ostream & | operator<< (std::ostream &, const CubicCurve &) |
Overloaded. More... | |
Cubic curves.
Cubic curves are implemented with three cubic polynomials defining the coordinates of the points on the curve. It is a minimum storage class in the sense that it does not keep extra constant data which may be useful for computing the bounding box of the quadric curve parameterized over the unit interval [0,1] or the distance between a point an the curve.
Creates a cubic curve.
x,y,z | Cubic equations of the coordinates. |
void CubicCurve::Approximate | ( | QuadricCurve & | a, |
QuadricCurve & | b, | ||
const double & | gamma = 0.5 |
||
) | const |
Approximate a cubic curve by two quadric curves.
N. Truong, C. Yuksel and L. Seiler. Quadratic Approximation of Cubic Curves. Proceedings of the ACM on Computer Graphics and Interactive Techniques. 2020.
gamma | Subdision parameter, in [0,1]. |
a,b | Returned quadric curves. |
|
static |
Creates a Bezier cubic curve on interval [0,1] given four vertex locations.
a,b,c,d | Vertices of the Bezier curve. |
|
inline |
Compute the i-th Bézier control point of the curve.
Computations have been optimized.
i | Index. |
double CubicCurve::Curvature | ( | const double & | t | ) | const |
Computes the 3D curvature to the curve at t.
t | Parameter. |
Vector CubicCurve::Eval | ( | const double & | t | ) | const |
Evaluates curve point at a given location.
t | Parameter. |
Box CubicCurve::GetBox | ( | ) | const |
Compute the bounding box of the cubic curve with parameter interval [0,1].
This function is computationnally intensive as the bounds are found by evaluating the range of every coordinate within [0,1].
Frame CubicCurve::GetFrame | ( | const double & | u | ) | const |
Compute the Frenet frame at a given point on the curve.
u | Parameter. |
Matrix CubicCurve::GetMatrix | ( | const double & | u | ) | const |
Compute the Frenet vectors at a given point on the curve.
The columns of the returned matrix contain the tangent, binormal and normal vectors.
u | Parameter. |
|
static |
Creates an Hermite cubic curve on interval [0,1] given vertex locations and tangent vectors (in that order).
a,b | End vertices of the Hermite cubic curve. |
ta,tb | Tangent vectors at the end vertices. |
double CubicCurve::InverseArcLength | ( | const double & | s, |
int | n = 256 |
||
) | const |
Compute the parameter t corresponding to a given input arc length.
s | Arc length, which should be positive. |
n | Discretization of the curve. |
double CubicCurve::Length | ( | const double & | a, |
const double & | b, | ||
int | n = 256 |
||
) | const |
Computes the length of the cubic curve over interval [a,b].
Since we have the parametric equations of the coordinates of the points on the curve, then the length is the integral of the square root of the sum of the squared derivatives where the limits of integration are [a,b].
s = Integral Sqrt((dx/dt)2 + (dy/dt)2) dt,
In the general case, the function we end up with is not integrable in closed form, leading to an elliptic integral or some such. Thus we evaluate the integral numerically.
a,b | Interval. |
n | Discretization of the integration interval. |
double CubicCurve::Length | ( | int | n = 256 | ) | const |
Computes the length of the cubic curve. Integration is performed over interval [0,1].
This function simply calls CubicCurve::Length(0.0,1.0,n) with n as the passed argument parameter.
n | Discretization of the curve. |
Vector CubicCurve::Normal | ( | const double & | t | ) | const |
Computes the normal vector to the cubic curve at a given position on the curve.
The normal is the obtained by evaluating the second derivative.
t | Position. |
Vector CubicCurve::operator() | ( | const double & | t | ) | const |
Evaluates curve point at a given location.
t | Parameter. |
double CubicCurve::R | ( | const Vector & | p, |
double & | u | ||
) | const |
Returns the squared distance between a point and the cubic curve.
This function computes the projection of a point p onto the curve by minimizing the distance function along the curve, expressed as a degree 5 polynomial.
Most of the coefficients of this polynomial are constant, and could be pre-processed in the constructor.
Note that this function is computationnally intensive, and ~25 times slower than QuadricCurve::R(). Therefore, cubic curves should be used with care as distance queries are called many times.
p | Point. |
u | Parameter defining the coordinate of the projection of the argument vertex onto the curve. |
double CubicCurve::S | ( | const double & | t, |
int | n = 256 |
||
) | const |
Compute the curvilign absisca of a point on the curve.
t | Parameter that should be within [0,1] interval. |
n | Discretization of the integration interval. |
QuadricCurve CubicCurve::Tangent | ( | ) | const |
Computes the quadric curve whose components are defined as the derivative of the cubic coordinates of the curve.
This function is useful for preprocessing tangent computations.
Vector CubicCurve::Tangent | ( | const double & | t | ) | const |
Computes the tangent to the cubic curve at a given position on the curve.
The tangent is the obtained by evaluating the first derivative.
t | Position. |
double CubicCurve::U | ( | const double & | s, |
int | n = 256 |
||
) | const |
Compute the parameter corresponding to the argument curvilign absisca of a point on the curve.
s | Argument curvilign absisca (should be between 0.0 and the length of the curve). |
n | Discretization of the integration interval. |
|
friend |
Overloaded.
s | Stream. |
curve | The cubic curve. |