Core 1.0
Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
QuadricCurve2 Class Reference

Quadric curves in the plane. More...

#include <curve.h>

Public Member Functions

 QuadricCurve2 ()
 Empty.
 
 QuadricCurve2 (const Quadric &, const Quadric &)
 Creates a quadric curve. More...
 
 QuadricCurve2 (const QuadricCurve &)
 Creates a quadric curve in the plane. More...
 
 ~QuadricCurve2 ()
 Empty.
 
Quadricoperator[] (int)
 Access curve components.
 
Quadric operator[] (int) const
 Access curve components.
 
QuadricCurve2 operator- () const
 Negates the coefficients of a quadric curve.
 
Vector2 operator() (const double &) const
 Computes the point on the curve. More...
 
Vector2 Eval (const double &) const
 Computes the point on the curve. More...
 
double Curvature (const double &) const
 Computes the signed curvature of the curve at a given point p(t). More...
 
Vector2 Tangent (const double &) const
 Computes the tangent to the curve. More...
 
Vector2 Normal (const double &) const
 Computes the normal vector to the quadric curve at a given position on the curve. More...
 
Box2 GetBox () const
 Compute the bounding box of the quadric curve with parameter interval [0,1].
 
void Translate (const Vector2 &)
 Translate the curve. More...
 
double R (const Vector2 &, double &) const
 Compute the squared distance between a point and the quadric 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...
 
double LengthIntegral (const double &=0.0, const double &=1.0) const
 Computes the length of the quadric curve over interval [a,b] using a closed form integral. More...
 
double Length (int=256) const
 Computes the length of the cubic curve. Integration is performed over interval [0,1].
 
double Length (const double &, const double &, int=256) const
 Computes the length of the quadric curve over interval [a,b]. More...
 
double UV (const Vector2 &, double &, double &) const
 Compute the inverse mapping for a given input point. More...
 
Vector2 Normal (const Vector2 &, double &) const
 Compute the projection of a point on the curve. More...
 
int Intersect (const Ray2 &, double[2]) const
 Compute the intersection between the curve and a ray. More...
 
void Draw (QGraphicsScene &, const QPen &=QPen(), const QBrush &=QBrush()) const
 Draw a quadric curve. More...
 

Static Public Member Functions

static QuadricCurve2 Bezier (const Vector2 &, const Vector2 &, const Vector2 &)
 Creates a quadratic Bezier curve on interval [0,1]. More...
 
static QVector< QuadricCurve2Bezier (const QVector< Vector2 > &)
 Create a set of quadratic Bezier curves. More...
 

Protected Attributes

Quadric y
 Quadric functions for every coordinate.
 

Friends

std::ostream & operator<< (std::ostream &, const QuadricCurve2 &)
 Overloaded. More...
 

Detailed Description

Quadric curves in the plane.

Quadric curves are implemented with two quadric 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.

Constructor & Destructor Documentation

◆ QuadricCurve2() [1/2]

QuadricCurve2::QuadricCurve2 ( const Quadric x,
const Quadric y 
)
explicit

Creates a quadric curve.

Parameters
x,yQuadric parametric equations of the corresponding x, y coordinates.

◆ QuadricCurve2() [2/2]

QuadricCurve2::QuadricCurve2 ( const QuadricCurve c)
explicit

Creates a quadric curve in the plane.

Parameters
cQuadric curve.

Member Function Documentation

◆ Bezier() [1/2]

QVector< QuadricCurve2 > QuadricCurve2::Bezier ( const QVector< Vector2 > &  c)
static

Create a set of quadratic Bezier curves.

Parameters
cControl points of the Bezier curve.

◆ Bezier() [2/2]

QuadricCurve2 QuadricCurve2::Bezier ( const Vector2 a,
const Vector2 b,
const Vector2 c 
)
static

Creates a quadratic Bezier curve on interval [0,1].

Parameters
a,b,cThe control points of the Bezier curve.

◆ Curvature()

double QuadricCurve2::Curvature ( const double &  t) const

Computes the signed curvature of the curve at a given point p(t).

Parameters
tParameter.

◆ Draw()

void QuadricCurve2::Draw ( QGraphicsScene &  scene,
const QPen &  pen = QPen(),
const QBrush &  brush = QBrush() 
) const

Draw a quadric curve.

Parameters
sceneGraphics scene.
penThe pen.
brushThe brush, should the triangle be filled.

◆ Eval()

Vector2 QuadricCurve2::Eval ( const double &  t) const

Computes the point on the curve.

Parameters
tParameter.

◆ Intersect()

int QuadricCurve2::Intersect ( const Ray2 ray,
double  t[2] 
) const

Compute the intersection between the curve and a ray.

Parameters
rayThe ray.
tIntersection depths.

◆ Length()

double QuadricCurve2::Length ( const double &  a,
const double &  b,
int  n = 256 
) const

Computes the length of the quadric 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.

Parameters
a,bInterval.
nDiscretization of the integration interval.

◆ LengthIntegral()

double QuadricCurve2::LengthIntegral ( const double &  a = 0.0,
const double &  b = 1.0 
) const

Computes the length of the quadric curve over interval [a,b] using a closed form integral.

Parameters
a,bInterval.

◆ Normal() [1/2]

Vector2 QuadricCurve2::Normal ( const double &  t) const

Computes the normal vector to the quadric curve at a given position on the curve.

The normal is the obtained by evaluating the second derivative.

Parameters
tPosition (not used).

◆ Normal() [2/2]

Vector2 QuadricCurve2::Normal ( const Vector2 p,
double &  u 
) const

Compute the projection of a point on the curve.

Parameters
pPoint.
uParameter defining the projected point.

◆ operator()()

Vector2 QuadricCurve2::operator() ( const double &  t) const

Computes the point on the curve.

Parameters
tParameter.

◆ R()

double QuadricCurve2::R ( const Vector2 p,
double &  u 
) const

Compute the squared distance between a point and the quadric curve.

This function computes the projection of the point p onto the curve by minimizing the distance function along the curve, expressed as a cubic polynomial.

Most of the coefficients of this cubic polynomial are constant, and could be pre-processed in the constructor.

Warning This function does not work if the quadric degenerates to a linear curve.

Parameters
pVertex.
uParameter defining the coordinate of the projection of the argument vertex onto the curve.

◆ S()

double QuadricCurve2::S ( const double &  t,
int  n = 256 
) const

Compute the curvilign absisca of a point on the curve.

Parameters
tParameter.
nDiscretization of the integration interval.

◆ Tangent()

Vector2 QuadricCurve2::Tangent ( const double &  t) const

Computes the tangent to the curve.

Parameters
tParameter.

◆ Translate()

void QuadricCurve2::Translate ( const Vector2 t)

Translate the curve.

Parameters
tTranslation vector.

◆ U()

double QuadricCurve2::U ( const double &  s,
int  n = 256 
) const

Compute the parameter corresponding to the argument curvilign absisca of a point on the curve.

Parameters
sArgument curvilign absisca (should be between 0.0 and the length of the curve).
nDiscretization of the integration interval.

◆ UV()

double QuadricCurve2::UV ( const Vector2 p,
double &  u,
double &  v 
) const

Compute the inverse mapping for a given input point.

Parameters
pPoint.
u,vInverse Coordinates, u will denote the position along the curve and v the signed distance to the curve.

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  s,
const QuadricCurve2 curve 
)
friend

Overloaded.

Parameters
sStream.
curveThe quadric curve.