wPlot2D version: 0.1.0
A lightweight C++ library for clear and customizable 2D scientific plots.
Loading...
Searching...
No Matches
wEngine::FunctionComponent Class Reference

ECS component that stores a mathematical function f(x). More...

#include <wFunctionComponent.hpp>

Inheritance diagram for wEngine::FunctionComponent:
Inheritance graph

Public Member Functions

 FunctionComponent (std::function< double(double) > function)
 Constructs a FunctionComponent with a given function.
virtual ~FunctionComponent ()=default
double calculate (double x) const
 Evaluates the stored function at a given x.
void debugPrint () const
Public Member Functions inherited from wEngine::Component
virtual ~Component ()=default
virtual void enable ()
virtual void disable ()
bool isEnabled () const
 Checks whether the component is currently active.
void setParent (Entity *parent)
 Sets the parent entity of this component.
EntitygetParent () const
 Returns the parent entity of this component.

Additional Inherited Members

Protected Member Functions inherited from wEngine::Component
 Component ()
 Protected constructor to restrict instantiation to derived classes.

Detailed Description

ECS component that stores a mathematical function f(x).

This component wraps a std::function< double( double ) > and provides an interface to evaluate the function at any given x-coordinate. It is mainly used by FunctionEntity to render mathematical curves.

Author
Wilfried Koch

Constructor & Destructor Documentation

◆ FunctionComponent()

wEngine::FunctionComponent::FunctionComponent ( std::function< double(double) > function)

Constructs a FunctionComponent with a given function.

Parameters
functionA callable object of type double( double ).
Exceptions
std::invalid_argumentif the provided function is empty.

◆ ~FunctionComponent()

virtual wEngine::FunctionComponent::~FunctionComponent ( )
virtualdefault

Member Function Documentation

◆ calculate()

double wEngine::FunctionComponent::calculate ( double x) const
nodiscard

Evaluates the stored function at a given x.

Parameters
xThe input value.
Returns
The result f(x).
Exceptions
std::runtime_errorif no function is set.

◆ debugPrint()

void wEngine::FunctionComponent::debugPrint ( ) const

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