mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/graph] GraphView: change the step with which the function is evaluated
to draw curve. Fix bug: polar function sin(5θ) was not drawn at all
This commit is contained in:
@@ -31,7 +31,18 @@ void GraphView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
Shared::CartesianFunction::PlotType type = f->plotType();
|
||||
float tmin = f->tMin();
|
||||
float tmax = f->tMax();
|
||||
float tstep = (tmax-tmin)/10.0f;
|
||||
/* The step is a fraction of tmax-tmin. We will evaluate the function at
|
||||
* every step and if the consecutive dots are close enough, we won't
|
||||
* evaluate any more dot within the step. We pick a very strange fraction
|
||||
* denominator to avoid evaluating a periodic function periodically. For
|
||||
* example, if tstep was (tmax - tmin)/10, the polar function r(θ) = sin(5θ)
|
||||
* defined on 0..2π would be evaluated on r(0) = 0, r(π/5) = 0, r(2*π/5) = 0
|
||||
* which would lead to no curve at all. With 10.0938275501223, the
|
||||
* problematic functions are the functions whose period is proportionned to
|
||||
* 10.0938275501223 which are hopefully rare enough.
|
||||
* TODO: The drawCurve algorithm should use the derivative function to know
|
||||
* how fast the function moves... */
|
||||
float tstep = (tmax-tmin)/10.0938275501223f;
|
||||
|
||||
// Cartesian
|
||||
if (type == Shared::CartesianFunction::PlotType::Cartesian) {
|
||||
|
||||
Reference in New Issue
Block a user