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

Quadric polynomials. More...

#include <quadric.h>

Public Member Functions

 Quadric ()
 Empty.
 
 Quadric (const double &, const double &, const double &)
 Creates a quadric.
 
 Quadric (const Linear &)
 Creates a quadric from a Linear polynomial.
 
 ~Quadric ()
 Empty.
 
constexpr double & operator[] (int)
 Access class components.
 
constexpr double operator[] (int) const
 Overloaded.
 
Quadric operator- () const
 Overloaded.
 
Quadricoperator+= (const Quadric &)
 Destructive sum of two polynomials.
 
Quadricoperator-= (const Quadric &)
 Destructive difference of two polynomials.
 
Quadricoperator*= (const double &)
 Scale a polynomial by a double value.
 
Quadricoperator/= (const double &)
 Scale a polynomial by a double value.
 
constexpr double operator() (const double &) const
 Evaluates the quadric.
 
constexpr double Derivative (const double &) const
 Computes the derivative value at a given point. More...
 
Linear Prime () const
 Compute the derivative of a quadric, which is a linear expression. More...
 
int Solve (double &, double &) const
 Solve quadratic equations. More...
 
int Solve (double *) const
 Solve quadratic equations. This function store the sorted roots in an array and returns the number of roots. More...
 
int Solve (double *, const double &, const double &) const
 Solve the quadratic equation over a given interval. More...
 
void Range (double &, double &, const double &=0.0, const double &=1.0) const
 This function computes the range of values taken by a quadric over a given interval. More...
 
double Maximum (const double &=0.0, const double &=1.0) const
 This function computes the maximum value taken by a quadric over a given interval. More...
 
double Minimum (const double &=0.0, const double &=1.0) const
 This function computes the minimum value taken by a quadric over a given interval. More...
 
double K (const double &, const double &) const
 Compute the Lipschitz constant of the quadric. More...
 

Static Public Member Functions

static Quadric Bezier (const double &, const double &, const double &)
 Creates a quadratic Bezier polynomial on interval [0,1]. More...
 
static double Smooth (const double &, const double &)
 Compute the value of the C1 smooth interpolating function (1-x/r)2. More...
 
static double Smooth (const double &)
 Compute the value of the C1 smooth interpolating function (1-x)2. More...
 
static double SmoothCompact (const double &, const double &)
 Compact support version of the smooth interpolating function Quadric::Smooth(). More...
 
static double SmoothCompact (const double &, const double &, const double &)
 Compact support version of the smooth interpolating function Quadric::Smooth() with interior and exterior radii. More...
 
static double Warp (const double &)
 Unit interval warping function. More...
 
static Quadric Bernstein (int)
 Creates a quadric Bernstein polynomial. More...
 
static double Bernstein (int, const double &)
 Compute the quadric Bernstein polynomial for a given value. More...
 

Static Public Attributes

static double epsilon = 1.0e-16
 Epsilon value used to check b2-4ac term in the root finding process.
 

Protected Attributes

double c [3] = { 0.0,0.0,0.0 }
 Array of coefficients.
 

Friends

Quadric operator+ (const Quadric &, const Quadric &)
 Overloaded.
 
Quadric operator- (const Quadric &, const Quadric &)
 Overloaded.
 
Quadric operator* (const Quadric &, const double &)
 Multiply a quadric by a scalar value.
 
Quadric operator* (const double &, const Quadric &)
 Overloaded.
 
Quadric operator/ (const Quadric &, const double &)
 Overloaded.
 
Quadric operator* (const Linear &, const Linear &)
 Multiply two linear polynomials.
 
std::ostream & operator<< (std::ostream &, const Quadric &)
 Overloaded output-stream operator. More...
 

Detailed Description

Quadric polynomials.

Constructors should provide the coefficients in descending order. is an example of how to code the quadric 2 x2-x+1:

Quadric p(2.0,-1.0,1.0);
Quadric polynomials.
Definition: quadric.h:8

Member Function Documentation

◆ Bernstein() [1/2]

Quadric Quadric::Bernstein ( int  p)
static

Creates a quadric Bernstein polynomial.

Parameters
pp-th polynomial.

◆ Bernstein() [2/2]

double Quadric::Bernstein ( int  p,
const double &  x 
)
static

Compute the quadric Bernstein polynomial for a given value.

Parameters
pp-th polynomial.
xReal.

◆ Bezier()

Quadric Quadric::Bezier ( const double &  a,
const double &  b,
const double &  c 
)
static

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

Parameters
a,b,cThe parameters of the Bézier polynomial.

Parameters are as follows:

c(t)=a (1-t)2+2b t(1-t)+c t2=(a-2b+c) t2+2(b-a) t+a

◆ Derivative()

constexpr double Quadric::Derivative ( const double &  x) const
inlineconstexpr

Computes the derivative value at a given point.

If only one evaluation is to be made, this function is more efficient than Prime() and then evaluating the derivative for a given input value.

Parameters
xReal.
See also
Quadric::Prime

◆ K()

double Quadric::K ( const double &  a,
const double &  b 
) const

Compute the Lipschitz constant of the quadric.

Parameters
a,bInterval.

◆ Maximum()

double Quadric::Maximum ( const double &  a = 0.0,
const double &  b = 1.0 
) const

This function computes the maximum value taken by a quadric over a given interval.

See also
Range
Parameters
a,bInterval.

◆ Minimum()

double Quadric::Minimum ( const double &  a = 0.0,
const double &  b = 1.0 
) const

This function computes the minimum value taken by a quadric over a given interval.

See also
Range
Parameters
a,bInterval.

◆ Prime()

Linear Quadric::Prime ( ) const
inline

Compute the derivative of a quadric, which is a linear expression.

See also
Quadric::Derivative

◆ Range()

void Quadric::Range ( double &  x,
double &  y,
const double &  a = 0.0,
const double &  b = 1.0 
) const

This function computes the range of values taken by a quadric over a given interval.

Bascially computes the roots of the first derivative, and evaluates the polynomial at the roots if they are within the interval bounds.

Parameters
a,bInterval.
x,yReturned range.

◆ Smooth() [1/2]

double Quadric::Smooth ( const double &  x)
inlinestatic

Compute the value of the C1 smooth interpolating function (1-x)2.

See also
Quadric::Smooth(const double&,const double&)
Parameters
xArgument value.

◆ Smooth() [2/2]

double Quadric::Smooth ( const double &  x,
const double &  r 
)
inlinestatic

Compute the value of the C1 smooth interpolating function (1-x/r)2.

See also
Cubic::Smooth(), Quadric::SmoothCompact
Parameters
xArgument value.
rRadius.

◆ SmoothCompact() [1/2]

double Quadric::SmoothCompact ( const double &  x,
const double &  r 
)
inlinestatic

Compact support version of the smooth interpolating function Quadric::Smooth().

Return Quadric::Smooth(x/r) if x<r and 0 otherwise.

See also
Cubic::Smooth(), Quadric::Smooth()
Parameters
xArgument value.
rRadius.

◆ SmoothCompact() [2/2]

double Quadric::SmoothCompact ( const double &  x,
const double &  e,
const double &  i 
)
inlinestatic

Compact support version of the smooth interpolating function Quadric::Smooth() with interior and exterior radii.

See also
Cubic::Smooth(), Quadric::Smooth()
Parameters
xArgument value.
i,eInterior and exterior radii.

◆ Solve() [1/3]

int Quadric::Solve ( double &  u,
double &  v 
) const

Solve quadratic equations.

This function uses two double arguments to store the roots and returns the number of roots.

Parameters
u,vThe two of roots, if they exist.

◆ Solve() [2/3]

int Quadric::Solve ( double *  y) const

Solve quadratic equations. This function store the sorted roots in an array and returns the number of roots.

Parameters
yThe array of roots.

◆ Solve() [3/3]

int Quadric::Solve ( double *  roots,
const double &  a,
const double &  b 
) const

Solve the quadratic equation over a given interval.

This function store the sorted roots in an array and returns the number of roots.

Parameters
rootsThe array of roots.
a,bThe interval.

◆ Warp()

double Quadric::Warp ( const double &  x)
inlinestatic

Unit interval warping function.

Remaps the unit interval into the unit interval by expanding the sides and compressing the center, keeping 1/2 mapped to 1/2.

Parameters
xReal in [0,1].

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  s,
const Quadric p 
)
friend

Overloaded output-stream operator.

Parameters
sStream.
pThe quadric.