Gazebo Math

API Reference

7.5.1
Polynomial3< T > Class Template Reference

The Polynomial3 class represents a cubic polynomial with real coefficients p(x) = c0 x^3 + c1 x^2 + c2 x + c3. More...

#include <gz/math/Polynomial3.hh>

Public Member Functions

 Polynomial3 ()=default
 Constructor. More...
 
 Polynomial3 (Vector4< T > _coeffs)
 Constructor. More...
 
const Vector4< T > & Coeffs () const
 Get the polynomial coefficients. More...
 
Evaluate (const T &_x) const
 Evaluate the polynomial at _x For non-finite _x, this function computes p(z) as z tends to _x. More...
 
Minimum () const
 Compute polynomial minimum. More...
 
Minimum (const Interval< T > &_interval) const
 Compute polynomial minimum in an _interval More...
 
Minimum (const Interval< T > &_interval, T &_xMin) const
 Compute polynomial minimum in an _interval More...
 
Minimum (T &_xMin) const
 Compute polynomial minimum. More...
 
operator() (const T &_x) const
 Call operator overload. More...
 
void Print (std::ostream &_out, const std::string &_x="x") const
 Prints polynomial as p(_x) to _out stream. More...
 

Static Public Member Functions

static Polynomial3 Constant (T _value)
 Make a constant polynomial. More...
 

Detailed Description

template<typename T>
class gz::math::Polynomial3< T >

The Polynomial3 class represents a cubic polynomial with real coefficients p(x) = c0 x^3 + c1 x^2 + c2 x + c3.

Example

#include <iostream>
int main(int argc, char **argv)
{
// A default constructed polynomial should have zero coefficients.
std::cout << "A default constructed polynomial is always: "
// A constant polynomial only has an independent term.
std::cout << "A constant polynomial only has an independent term: "
// A cubic polynomial may be incomplete.
gz::math::Vector4d(1., 0., -1., 2.));
std::cout << "A cubic polynomial may be incomplete: " << p << std::endl;
// A polynomial can be evaluated.
const double x = 0.5;
std::cout << "Evaluating " << p << " at " << x
<< " yields " << p(x) << std::endl;
// A polynomial can be queried for its minimum in a given interval,
// as well as for its global minimum (which may not always be finite).
const gz::math::Intervald interval =
std::cout << "The minimum of " << p << " in the " << interval
<< " interval is " << p.Minimum(interval) << std::endl;
std::cout << "The global minimum of " << p
<< " is " << p.Minimum() << std::endl;
gz::math::Vector4d(0., 1., 2., 1.));
std::cout << "The minimum of " << q << " in the " << interval
<< " interval is " << q.Minimum(interval) << std::endl;
std::cout << "The global minimum of " << q
<< " is " << q.Minimum() << std::endl;
}

Constructor & Destructor Documentation

◆ Polynomial3() [1/2]

Polynomial3 ( )
default

Constructor.

Referenced by Polynomial3< T >::Constant().

◆ Polynomial3() [2/2]

Polynomial3 ( Vector4< T >  _coeffs)
inlineexplicit

Constructor.

Parameters
[in]_coeffscoefficients c0 through c3, left to right

Member Function Documentation

◆ Coeffs()

const Vector4<T>& Coeffs ( ) const
inline

Get the polynomial coefficients.

Returns
this polynomial coefficients

◆ Constant()

static Polynomial3 Constant ( _value)
inlinestatic

Make a constant polynomial.

Returns
a p(x) = _value polynomial

References Polynomial3< T >::Polynomial3().

◆ Evaluate()

T Evaluate ( const T &  _x) const
inline

Evaluate the polynomial at _x For non-finite _x, this function computes p(z) as z tends to _x.

Parameters
[in]_xpolynomial argument
Returns
the result of evaluating p(_x)

References std::copysign(), numeric_limits::epsilon(), std::isfinite(), gz::math::isnan(), and std::isnan().

Referenced by Polynomial3< T >::Minimum(), and Polynomial3< T >::operator()().

◆ Minimum() [1/4]

T Minimum ( ) const
inline

Compute polynomial minimum.

Returns
the polynomial minimum (may not be finite)

Referenced by Polynomial3< T >::Minimum().

◆ Minimum() [2/4]

T Minimum ( const Interval< T > &  _interval) const
inline

Compute polynomial minimum in an _interval

Parameters
[in]_intervalpolynomial argument interval to check
Returns
the polynomial minimum in the given interval (may not be finite), or NaN if the interval is empty

References Polynomial3< T >::Minimum().

◆ Minimum() [3/4]

T Minimum ( const Interval< T > &  _interval,
T &  _xMin 
) const
inline

Compute polynomial minimum in an _interval

Parameters
[in]_intervalpolynomial argument interval to check
[out]_xMinpolynomial argument that yields minimum, or NaN if the interval is empty
Returns
the polynomial minimum in the given interval, or NaN if the interval is empty

References Interval< T >::Contains(), Interval< T >::Empty(), numeric_limits::epsilon(), Polynomial3< T >::Evaluate(), Interval< T >::LeftValue(), numeric_limits::quiet_NaN(), Interval< T >::RightValue(), and std::sqrt().

◆ Minimum() [4/4]

T Minimum ( T &  _xMin) const
inline

Compute polynomial minimum.

Parameters
[out]_xMinpolynomial argument that yields minimum
Returns
the polynomial minimum (may not be finite)

References Polynomial3< T >::Minimum().

◆ operator()()

T operator() ( const T &  _x) const
inline

Call operator overload.

See also
Polynomial3::Evaluate()

References Polynomial3< T >::Evaluate().

◆ Print()

void Print ( std::ostream _out,
const std::string _x = "x" 
) const
inline

Prints polynomial as p(_x) to _out stream.

Parameters
[in]_outOutput stream to print to
[in]_xArgument name to be used

References numeric_limits::epsilon().


The documentation for this class was generated from the following file: