Skip to content

Commit

Permalink
Parabola: extremArg() and extremVal()
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedr committed Jun 21, 2024
1 parent 0deeaf8 commit 2c8991e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions source/MRMesh/MRParabola.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ struct Parabola

/// compute value of quadratic function at any x
constexpr T operator() ( T x ) const { return a*x*x + b*x + c; }

/// argument (x) where parabola reaches extremal value: minimum for a > 0, maximum for a < 0
constexpr T extremArg() const { return -b / (2 * a); }

/// value (y) where parabola reaches extremal value: minimum for a > 0, maximum for a < 0
constexpr T extremVal() const { return -b*b / (4 * a) + c; }
};

} //namespace MR

0 comments on commit 2c8991e

Please sign in to comment.