mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[apps/graph] Fixed cache step quirks
Change-Id: I5b630301ab2a4b17a5a4d77c7d9a05120449e55e
This commit is contained in:
committed by
Émilie Feral
parent
1bee23cf4f
commit
beb228fa78
@@ -40,18 +40,8 @@ void GraphView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
}
|
||||
float tmin = f->tMin();
|
||||
float tmax = f->tMax();
|
||||
/* 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;
|
||||
|
||||
float tstep = (tmax-tmin)/k_graphStepDenominator;
|
||||
|
||||
float tCacheMin, tCacheStep;
|
||||
if (type == ContinuousFunction::PlotType::Cartesian) {
|
||||
@@ -60,7 +50,7 @@ void GraphView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
tCacheStep = pixelWidth();
|
||||
} else {
|
||||
tCacheMin = tmin;
|
||||
tCacheStep = tstep;
|
||||
tCacheStep = tstep / ContinuousFunctionCache::k_parametricStepFactor;
|
||||
}
|
||||
ContinuousFunctionCache::PrepareForCaching(f.operator->(), cch, tCacheMin, tCacheStep);
|
||||
|
||||
|
||||
@@ -7,6 +7,19 @@ namespace Graph {
|
||||
|
||||
class GraphView : public Shared::FunctionGraphView {
|
||||
public:
|
||||
/* 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... */
|
||||
static constexpr float k_graphStepDenominator = 10.0938275501223f;
|
||||
|
||||
GraphView(Shared::InteractiveCurveViewRange * graphRange,
|
||||
Shared::CurveViewCursor * cursor, Shared::BannerView * bannerView, Shared::CursorView * cursorView);
|
||||
void reload() override;
|
||||
|
||||
Reference in New Issue
Block a user