MeshLib Documentation
Loading...
Searching...
No Matches
MRParabola.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMeshFwd.h"
4
5namespace MR
6{
7
9template <typename T>
11{
12 T a = 0;
13 T b = 0;
14 T c = 0;
15
16 constexpr Parabola() noexcept = default;
17 constexpr Parabola( T a, T b, T c ) : a( a ), b( b ), c( c ) { }
18 template <typename U>
19 constexpr explicit Parabola( const Parabola<U> & p ) : a( T( p.a ) ), b( T( p.b ) ), c( T( p.c ) ) { }
20
22 constexpr T operator() ( T x ) const { return a*x*x + b*x + c; }
23
25 constexpr T extremArg() const { return -b / (2 * a); }
26
28 constexpr T extremVal() const { return -b*b / (4 * a) + c; }
29};
30
31} //namespace MR
Definition MRCameraOrientationPlugin.h:8
Represents quadratic function f(x) = a*x*x + b*x + c.
Definition MRParabola.h:11
constexpr Parabola() noexcept=default
constexpr T extremVal() const
value (y) where parabola reaches extremal value: minimum for a > 0, maximum for a < 0
Definition MRParabola.h:28
T a
Definition MRParabola.h:12
constexpr T extremArg() const
argument (x) where parabola reaches extremal value: minimum for a > 0, maximum for a < 0
Definition MRParabola.h:25
constexpr Parabola(const Parabola< U > &p)
Definition MRParabola.h:19
constexpr T operator()(T x) const
compute value of quadratic function at any x
Definition MRParabola.h:22
T c
Definition MRParabola.h:14
T b
Definition MRParabola.h:13