32 return value >=
start && value <=
end;
37 return std::clamp(value,
start,
end);
46 Pwl(
const std::vector<Point> &points);
47 Pwl(std::vector<Point> &&points);
49 void append(
double x,
double y,
double eps = 1e-6);
51 bool empty()
const {
return points_.empty(); }
52 void clear() { points_.clear(); }
53 size_t size()
const {
return points_.size(); }
58 double eval(
double x,
int *span =
nullptr,
59 bool updateSpan =
true)
const;
61 std::pair<Pwl, bool>
inverse(
double eps = 1e-6)
const;
64 void map(std::function<
void(
double x,
double y)> f)
const;
68 std::function<
double(
double x,
double y0,
double y1)> f,
76 static void map2(
const Pwl &pwl0,
const Pwl &pwl1,
77 std::function<
void(
double x,
double y0,
double y1)> f);
78 void prepend(
double x,
double y,
double eps = 1e-6);
79 int findSpan(
double x,
int span)
const;
81 std::vector<Point> points_;
Interval range() const
Get the range of the piecewise linear function.
Definition: pwl.cpp:186
std::string toString() const
Assemble and return a string describing the piecewise linear function.
Definition: pwl.cpp:415
Pwl compose(const Pwl &other, double eps=1e-6) const
Compose two piecewise linear functions together.
Definition: pwl.cpp:289
double clamp(double value)
Clamp a value such that it is within the interval.
Definition: pwl.h:35
bool contains(double value)
Check if a given value falls within the interval.
Definition: pwl.h:30
Describe an interval in one-dimensional real space.
Definition: pwl.h:26
Interval domain() const
Get the domain of the piecewise linear function.
Definition: pwl.cpp:177
std::pair< Pwl, bool > inverse(double eps=1e-6) const
Compute the inverse function.
Definition: pwl.cpp:248
Top-level libcamera namespace.
Definition: backtrace.h:17
Describe a univariate piecewise linear function in two-dimensional real space.
Definition: pwl.h:21
double start
Start of the interval.
Definition: pwl.h:42
Pwl()
Construct an empty piecewise linear function.
Definition: pwl.cpp:99
bool empty() const
Check if the piecewise linear function is empty.
Definition: pwl.h:51
void map(std::function< void(double x, double y)> f) const
Apply function to (x, y) values at every control point.
Definition: pwl.cpp:338
double eval(double x, int *span=nullptr, bool updateSpan=true) const
Evaluate the piecewise linear function.
Definition: pwl.cpp:207
void append(double x, double y, double eps=1e-6)
Append a point to the end of the piecewise linear function.
Definition: pwl.cpp:135
void clear()
Clear the piecewise linear function.
Definition: pwl.h:52
double end
End of the interval.
Definition: pwl.h:42
Interval(double _start, double _end)
Construct an interval.
Definition: pwl.h:27
size_t size() const
Retrieve the number of points in the piecewise linear function.
Definition: pwl.h:53
double length() const
Compute the length of the interval.
Definition: pwl.h:40
Pwl & operator*=(double d)
Multiply the piecewise linear function.
Definition: pwl.cpp:404
static Pwl combine(const Pwl &pwl0, const Pwl &pwl1, std::function< double(double x, double y0, double y1)> f, double eps=1e-6)
Combine two Pwls.
Definition: pwl.cpp:388