diff --git a/apps/graph/function.cpp b/apps/graph/function.cpp index d0e6a316f..f96a0c8e7 100644 --- a/apps/graph/function.cpp +++ b/apps/graph/function.cpp @@ -58,3 +58,10 @@ bool Graph::Function::isActive() { void Graph::Function::setActive(bool active) { m_active = active; } + +float Graph::Function::evaluateAtAbscissa(float x) { + Context plotContext; + Float xExp = Float(x); + plotContext.setExpressionForSymbolName(&xExp, "x"); + return m_expression->approximate(plotContext); +} diff --git a/apps/graph/function.h b/apps/graph/function.h index 58d2b3fb1..154fefeba 100644 --- a/apps/graph/function.h +++ b/apps/graph/function.h @@ -9,6 +9,7 @@ namespace Graph { class Function { public: static constexpr const char * Parameter = "(x)"; + Function(const char * text = nullptr, KDColor color = KDColorBlack); ~Function(); // Delete expression and layout, if needed const char * text(); @@ -20,6 +21,7 @@ public: void setActive(bool active); void setContent(const char * c); void setColor(KDColor m_color); + float evaluateAtAbscissa(float x); private: constexpr static int k_bodyLength = 255; char m_text[k_bodyLength];