Core 1.0
|
Cubic curves in the plane. More...
#include <curve.h>
Public Member Functions | |
CubicCurve2 () | |
Empty. | |
CubicCurve2 (const Cubic &, const Cubic &) | |
Creates a cubic curve. More... | |
CubicCurve2 (const CubicCurve &) | |
Creates a cubic curve. More... | |
~CubicCurve2 () | |
Empty. | |
Cubic & | operator[] (int) |
Access curve components. | |
Cubic | operator[] (int) const |
Access curve components. | |
CubicCurve | ToCubicCurve (const Cubic &=Cubic(0.0, 0.0, 0.0, 0.0)) const |
Convert a planar cubic curve to a cubic curve. More... | |
CubicCurve2 | operator- () const |
Negative curve unary operator. | |
QuadricCurve2 | Tangent () const |
Computes the quadric curve whose components are the derivatives of the curve. More... | |
Vector2 | Tangent (const double &) const |
Computes the tangent to the cubic curve at a given position on the curve. More... | |
Vector2 | Normal (const double &) const |
Computes the normal vector to the cubic curve at a given position on the curve. 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... | |
int | Intersect (const Ray2 &, double[3]) const |
Compute the intersection between the curve and a ray. 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... | |
Vector2 | operator() (const double &) const |
Evaluates curve point at a given location. More... | |
Vector2 | Eval (const double &) const |
Evaluates curve point at a given location. More... | |
double | Curvature (const double &) const |
Computes the signed curvature of the curve at a given point p(t). More... | |
double | Curvature (const double &, const double &) const |
Compute the maximum curvature over a given interval. More... | |
Box2 | GetBox () const |
Compute the bounding box of the cubic curve with parameter interval [0,1]. | |
double | R (const Vector2 &, double &) const |
Compute the squared distance between a point in the plane and the cubic curve. More... | |
Vector2 | Normal (const Vector2 &, double &) const |
Compute the projection of a point on the curve. More... | |
double | UV (const Vector2 &, double &, double &) const |
Compute the inverse mapping for a given input point. More... | |
Vector2 | UV (const Vector2 &) const |
Compute the inverse mapping for a given input point. More... | |
Matrix2 | GetMatrix (const double &) const |
Compute the Frenet vectors (tangent and normal) at a given point on the curve. More... | |
Frame2 | GetFrame (const double &) const |
Compute the frame at a given point on the curve. More... | |
Vector2 | BezierControl (int) const |
Compute the i-th Bézier control point of the curve. More... | |
void | Draw (QGraphicsScene &, const QPen &=QPen(), const QBrush &=QBrush()) const |
Draw a cubic curve. More... | |
Static Public Member Functions | |
static CubicCurve2 | Hermite (const Vector2 &, const Vector2 &, const Vector2 &, const Vector2 &) |
Creates an Hermite cubic curve on interval [0,1] given vertex locations and tangent vectors (in that order). More... | |
static CubicCurve2 | Bezier (const Vector2 &, const Vector2 &, const Vector2 &, const Vector2 &) |
Creates a Bezier cubic curve on interval [0,1] given four vertex locations. More... | |
Protected Attributes | |
Cubic | y |
Cubic polynomial functions for every coordinate. | |
Friends | |
std::ostream & | operator<< (std::ostream &, const CubicCurve2 &) |
Overloaded. More... | |
Cubic curves in the plane.
Creates a cubic curve.
x,y | Cubic parametric equations of the corresponding x, y coordinates. |
|
explicit |
Creates a cubic curve.
c | Cubic curve. |
|
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 CubicCurve2::Curvature | ( | const double & | t | ) | const |
Computes the signed curvature of the curve at a given point p(t).
t | Parameter. |
double CubicCurve2::Curvature | ( | const double & | a, |
const double & | b | ||
) | const |
Compute the maximum curvature over a given interval.
Compute the analytic equation of the numerator of the curvature expression, search the roots, find extrema and returns the maximum.
a,b | Interval |
void CubicCurve2::Draw | ( | QGraphicsScene & | scene, |
const QPen & | pen = QPen() , |
||
const QBrush & | = QBrush() |
||
) | const |
Draw a cubic curve.
The brush is not used.
scene | Graphics scene. |
pen | The pen. |
Vector2 CubicCurve2::Eval | ( | const double & | t | ) | const |
Evaluates curve point at a given location.
t | Parameter. |
Frame2 CubicCurve2::GetFrame | ( | const double & | u | ) | const |
Compute the frame at a given point on the curve.
u | Parameter. |
Matrix2 CubicCurve2::GetMatrix | ( | const double & | u | ) | const |
Compute the Frenet vectors (tangent and normal) at a given point on the curve.
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. |
int CubicCurve2::Intersect | ( | const Ray2 & | ray, |
double | t[3] | ||
) | const |
Compute the intersection between the curve and a ray.
ray | The ray. |
t | Intersection depths. |
double CubicCurve2::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 CubicCurve2::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].
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 CubicCurve2::Length | ( | int | n = 256 | ) | const |
Computes the length of the cubic curve. Integration is performed over interval [0,1].
Simply call CubicCurve::Length(0.0,1.0,n) with n as the passed argument parameter.
n | Discretization of the curve. |
Vector2 CubicCurve2::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. |
Compute the projection of a point on the curve.
p | Point. |
u | Parameter defining the projected point. |
Vector2 CubicCurve2::operator() | ( | const double & | t | ) | const |
Evaluates curve point at a given location.
t | Parameter. |
double CubicCurve2::R | ( | const Vector2 & | p, |
double & | u | ||
) | const |
Compute the squared distance between a point in the plane 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.
p | Point. |
u | Parameter defining the coordinate of the projection of the argument vertex onto the curve. |
double CubicCurve2::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. |
QuadricCurve2 CubicCurve2::Tangent | ( | ) | const |
Computes the quadric curve whose components are the derivatives of the curve.
This function is useful for preprocessing tangent computations.
Vector2 CubicCurve2::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. |
|
inline |
Convert a planar cubic curve to a cubic curve.
This is a convenience function, which is basically the same as:
z | Missing cubic. |
double CubicCurve2::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. |
Compute the inverse mapping for a given input point.
p | Point. |
double CubicCurve2::UV | ( | const Vector2 & | p, |
double & | u, | ||
double & | v | ||
) | const |
Compute the inverse mapping for a given input point.
p | Point. |
u,v | Inverse Coordinates, u will denote the position along the curve and v the signed distance to the curve. |
|
friend |
Overloaded.
s | Stream. |
curve | The cubic curve. |