FuncSketch
Loading...
Searching...
No Matches
func_sketch::plotter::FunctionSampler Class Reference

Class to sample functions for plotting. More...

#include <func_sketch/plotter/function_sampler.h>

Collaboration diagram for func_sketch::plotter::FunctionSampler:

Public Member Functions

 FunctionSampler (const PlotRange &range, const PlotConfig &config)
 Constructor.
FunctionSamplerrange (const PlotRange &value)
 Set the range of plots.
FunctionSamplerconfig (const PlotConfig &value)
 Set the configuration of plots.
std::vector< Pointoperator() (const expressions::Expression &function) const
 Sample a function for plotting.

Private Member Functions

std::vector< Pointsample_initial_points (const expressions::Expression &function) const
 Sample initial points.
std::vector< Pointsample_adaptive_points (const expressions::Expression &function, const std::vector< Point > &initial_samples) const
 Sample additional points adaptively.
bool divide_segment_according_to_y_change (const expressions::Expression &function, std::vector< Point > &samples, std::size_t left_index) const
 Divide if the change of y is large.
bool divide_segment_according_to_slope_change (const expressions::Expression &function, std::vector< Point > &samples, std::size_t left_index) const
 Divide if the change of slope of y is large.
bool divide_segment_when_one_end_is_not_finite (const expressions::Expression &function, std::vector< Point > &samples, std::size_t left_index) const
 Divide if one end of the segment is not finite.
bool divide_segment (const expressions::Expression &function, std::vector< Point > &samples, std::size_t left_index) const
 Divide a segment into two segments in sample points if applicable.
Point sample_additional_point (const expressions::Expression &function, const Point &left_point, const Point &right_point) const
 Sample an additional point between two points.
bool is_sampling_should_be_skipped (const Point &left_point, const Point &right_point) const
 Check the condition to skip sampling of a point between two points.

Private Attributes

PlotRange range_
 Range of plots.
PlotConfig config_
 Configuration of plots.
expressions::ExpressionEvaluator evaluator_
 Evaluator of expressions.

Detailed Description

Class to sample functions for plotting.

Definition at line 35 of file function_sampler.h.

Constructor & Destructor Documentation

◆ FunctionSampler()

func_sketch::plotter::FunctionSampler::FunctionSampler ( const PlotRange & range,
const PlotConfig & config )

Constructor.

Parameters
[in]rangeRange of plots.
[in]configConfiguration of plots.

Definition at line 28 of file function_sampler.cpp.

Member Function Documentation

◆ range()

FunctionSampler & func_sketch::plotter::FunctionSampler::range ( const PlotRange & value)

Set the range of plots.

Parameters
[in]valueRange of plots.
Returns
Reference to this object.

Definition at line 33 of file function_sampler.cpp.

◆ config()

FunctionSampler & func_sketch::plotter::FunctionSampler::config ( const PlotConfig & value)

Set the configuration of plots.

Parameters
[in]valueConfiguration of plots.
Returns
Reference to this object.

Definition at line 38 of file function_sampler.cpp.

◆ operator()()

std::vector< Point > func_sketch::plotter::FunctionSampler::operator() ( const expressions::Expression & function) const
nodiscard

Sample a function for plotting.

Parameters
[in]functionFunction to sample.
Returns
Sampled points of the function.

Definition at line 43 of file function_sampler.cpp.

◆ sample_initial_points()

std::vector< Point > func_sketch::plotter::FunctionSampler::sample_initial_points ( const expressions::Expression & function) const
nodiscardprivate

Sample initial points.

Parameters
[in]functionFunction to sample.
Returns
Sampled points of the function.

Definition at line 49 of file function_sampler.cpp.

◆ sample_adaptive_points()

std::vector< Point > func_sketch::plotter::FunctionSampler::sample_adaptive_points ( const expressions::Expression & function,
const std::vector< Point > & initial_samples ) const
nodiscardprivate

Sample additional points adaptively.

Parameters
[in]functionFunction to sample.
[in]initial_samplesInitial sampled points.
Returns
Sampled points of the function.

Definition at line 68 of file function_sampler.cpp.

◆ divide_segment_according_to_y_change()

bool func_sketch::plotter::FunctionSampler::divide_segment_according_to_y_change ( const expressions::Expression & function,
std::vector< Point > & samples,
std::size_t left_index ) const
nodiscardprivate

Divide if the change of y is large.

Parameters
[in]functionFunction to sample.
[in,out]samplesSampled points of the function.
[in]left_indexIndex of the left point of the segment to check.
Return values
trueThe segment was divided into two segments.
falseThe segment was not divided into two segments.

Definition at line 124 of file function_sampler.cpp.

◆ divide_segment_according_to_slope_change()

bool func_sketch::plotter::FunctionSampler::divide_segment_according_to_slope_change ( const expressions::Expression & function,
std::vector< Point > & samples,
std::size_t left_index ) const
nodiscardprivate

Divide if the change of slope of y is large.

Parameters
[in]functionFunction to sample.
[in,out]samplesSampled points of the function.
[in]left_indexIndex of the left point of the segment to check.
Return values
trueThe segment was divided into two segments.
falseThe segment was not divided into two segments.

Definition at line 139 of file function_sampler.cpp.

◆ divide_segment_when_one_end_is_not_finite()

bool func_sketch::plotter::FunctionSampler::divide_segment_when_one_end_is_not_finite ( const expressions::Expression & function,
std::vector< Point > & samples,
std::size_t left_index ) const
nodiscardprivate

Divide if one end of the segment is not finite.

Parameters
[in]functionFunction to sample.
[in,out]samplesSampled points of the function.
[in]left_indexIndex of the left point of the segment to check.
Return values
trueThe segment was divided into two segments.
falseThe segment was not divided into two segments.

Definition at line 166 of file function_sampler.cpp.

◆ divide_segment()

bool func_sketch::plotter::FunctionSampler::divide_segment ( const expressions::Expression & function,
std::vector< Point > & samples,
std::size_t left_index ) const
nodiscardprivate

Divide a segment into two segments in sample points if applicable.

Parameters
[in]functionFunction to sample.
[in,out]samplesSampled points of the function.
[in]left_indexIndex of the left point of the segment.
Return values
trueThe segment was divided into two segments.
falseThe segment was not divided into two segments.
Note
This function checks the condition to skip sampling, and does sample if the condition is not satisfied.

Definition at line 180 of file function_sampler.cpp.

◆ sample_additional_point()

Point func_sketch::plotter::FunctionSampler::sample_additional_point ( const expressions::Expression & function,
const Point & left_point,
const Point & right_point ) const
nodiscardprivate

Sample an additional point between two points.

Parameters
[in]functionFunction to sample.
[in]left_pointLeft point.
[in]right_pointRight point.
Returns
Sampled point of the function.

Definition at line 195 of file function_sampler.cpp.

◆ is_sampling_should_be_skipped()

bool func_sketch::plotter::FunctionSampler::is_sampling_should_be_skipped ( const Point & left_point,
const Point & right_point ) const
nodiscardprivate

Check the condition to skip sampling of a point between two points.

Parameters
[in]left_pointLeft point.
[in]right_pointRight point.
Return values
trueDo not sample a point between the two points.
falseSample a point between the two points.

Definition at line 204 of file function_sampler.cpp.

Member Data Documentation

◆ range_

PlotRange func_sketch::plotter::FunctionSampler::range_
private

Range of plots.

Definition at line 170 of file function_sampler.h.

◆ config_

PlotConfig func_sketch::plotter::FunctionSampler::config_
private

Configuration of plots.

Definition at line 173 of file function_sampler.h.

◆ evaluator_

expressions::ExpressionEvaluator func_sketch::plotter::FunctionSampler::evaluator_
private

Evaluator of expressions.

Definition at line 176 of file function_sampler.h.


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