mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[apps/graph] Use CartesianFunction::nextIntersectionFrom in
PreimageGraphController to compute the preimage
This commit is contained in:
@@ -47,7 +47,7 @@ Poincare::Coordinate2D<double> IntersectionGraphController::computeNewPointOfInt
|
||||
Ion::Storage::Record record = functionStore()->activeRecordAtIndex(i);
|
||||
if (record != m_record) {
|
||||
CartesianFunction f = *(functionStore()->modelForRecord(record));
|
||||
Poincare::Coordinate2D<double> intersection = functionStore()->modelForRecord(m_record)->nextIntersectionFrom(start, step, max, context, &f);
|
||||
Poincare::Coordinate2D<double> intersection = functionStore()->modelForRecord(m_record)->nextIntersectionFrom(start, step, max, context, f.expressionReduced(context), f.tMin(), f.tMax());
|
||||
if ((std::isnan(result.x1()) || std::fabs(intersection.x1()-start) < std::fabs(result.x1()-start)) && !std::isnan(intersection.x1())) {
|
||||
m_intersectedRecord = record;
|
||||
result = (std::isnan(result.x1()) || std::fabs(intersection.x1()-start) < std::fabs(result.x1()-start)) ? intersection : result;
|
||||
|
||||
@@ -24,12 +24,8 @@ PreimageGraphController::PreimageGraphController(
|
||||
}
|
||||
|
||||
Poincare::Coordinate2D<double> PreimageGraphController::computeNewPointOfInterest(double start, double step, double max, Poincare::Context * context) {
|
||||
// TODO The following three lines should be factored.
|
||||
constexpr int bufferSize = CodePoint::MaxCodePointCharLength + 1;
|
||||
char unknownX[bufferSize];
|
||||
Poincare::SerializationHelper::CodePoint(unknownX, bufferSize, UCodePointUnknownX);
|
||||
Poincare::Expression expression = Poincare::Float<double>::Builder(m_image);
|
||||
return Shared::PoincareHelpers::NextIntersection(functionStore()->modelForRecord(m_record)->expressionReduced(context), unknownX, start, step, max, context, expression);
|
||||
return functionStore()->modelForRecord(m_record)->nextIntersectionFrom(start, step, max, context, expression);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -286,13 +286,13 @@ Coordinate2D<double> CartesianFunction::nextRootFrom(double start, double step,
|
||||
return nextPointOfInterestFrom(start, step, max, context, [](Expression e, char * symbol, double start, double step, double max, Context * context) { return Coordinate2D<double>(PoincareHelpers::NextRoot(e, symbol, start, step, max, context), 0.0); });
|
||||
}
|
||||
|
||||
Coordinate2D<double> CartesianFunction::nextIntersectionFrom(double start, double step, double max, Poincare::Context * context, CartesianFunction * f) const {
|
||||
Coordinate2D<double> CartesianFunction::nextIntersectionFrom(double start, double step, double max, Poincare::Context * context, Poincare::Expression e, double eDomainMin, double eDomainMax) const {
|
||||
assert(plotType() == PlotType::Cartesian);
|
||||
constexpr int bufferSize = CodePoint::MaxCodePointCharLength + 1;
|
||||
char unknownX[bufferSize];
|
||||
SerializationHelper::CodePoint(unknownX, bufferSize, UCodePointUnknownX);
|
||||
double domainMin = maxDouble(tMin(), f->tMin());
|
||||
double domainMax = minDouble(tMax(), f->tMax());
|
||||
double domainMin = maxDouble(tMin(), eDomainMin);
|
||||
double domainMax = minDouble(tMax(), eDomainMax);
|
||||
if (step > 0.0f) {
|
||||
start = maxDouble(start, domainMin);
|
||||
max = minDouble(max, domainMax);
|
||||
@@ -300,7 +300,7 @@ Coordinate2D<double> CartesianFunction::nextIntersectionFrom(double start, doubl
|
||||
start = minDouble(start, domainMax);
|
||||
max = maxDouble(max, domainMin);
|
||||
}
|
||||
return PoincareHelpers::NextIntersection(expressionReduced(context), unknownX, start, step, max, context, f->expressionReduced(context));
|
||||
return PoincareHelpers::NextIntersection(expressionReduced(context), unknownX, start, step, max, context, e);
|
||||
}
|
||||
|
||||
Coordinate2D<double> CartesianFunction::nextPointOfInterestFrom(double start, double step, double max, Context * context, ComputePointOfInterest compute) const {
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
Poincare::Coordinate2D<double> nextMaximumFrom(double start, double step, double max, Poincare::Context * context) const;
|
||||
// Roots
|
||||
Poincare::Coordinate2D<double> nextRootFrom(double start, double step, double max, Poincare::Context * context) const;
|
||||
Poincare::Coordinate2D<double> nextIntersectionFrom(double start, double step, double max, Poincare::Context * context, CartesianFunction * f) const;
|
||||
Poincare::Coordinate2D<double> nextIntersectionFrom(double start, double step, double max, Poincare::Context * context, Poincare::Expression e, double eDomainMin = -INFINITY, double eDomainMax = INFINITY) const;
|
||||
private:
|
||||
constexpr static float k_polarParamRangeSearchNumberOfPoints = 100.0f; // This is ad hoc, no special justification
|
||||
typedef Poincare::Coordinate2D<double> (*ComputePointOfInterest)(Poincare::Expression e, char * symbol, double start, double step, double max, Poincare::Context * context);
|
||||
|
||||
Reference in New Issue
Block a user