MeshLib C++ Docs
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{
9
10
12template <typename T>
14{
15 T a = 0;
16 T b = 0;
17 T c = 0;
18
19 constexpr Parabola() noexcept = default;
20 constexpr Parabola( T a, T b, T c ) : a( a ), b( b ), c( c ) { }
21 template <typename U>
22 constexpr explicit Parabola( const Parabola<U> & p ) : a( T( p.a ) ), b( T( p.b ) ), c( T( p.c ) ) { }
23
25 constexpr T operator() ( T x ) const { return a*x*x + b*x + c; }
26
28 constexpr T extremArg() const { return -b / (2 * a); }
29
31 constexpr T extremVal() const { return -b*b / (4 * a) + c; }
32};
33
34}
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:31
T a
Definition MRParabola.h:15
constexpr T extremArg() const
argument (x) where parabola reaches extremal value: minimum for a > 0, maximum for a < 0
Definition MRParabola.h:28
constexpr Parabola(const Parabola< U > &p)
Definition MRParabola.h:22
constexpr T operator()(T x) const
compute value of quadratic function at any x
Definition MRParabola.h:25
T c
Definition MRParabola.h:17
T b
Definition MRParabola.h:16
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Represents quadratic function f(x) = a*x*x + b*x + c.
Definition MRParabola.h:14