mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[poincare/coordinate2D] Rename member values to x and y
This commit is contained in:
@@ -20,13 +20,13 @@ CalculationGraphController::CalculationGraphController(Responder * parentRespond
|
||||
void CalculationGraphController::viewWillAppear() {
|
||||
assert(!m_record.isNull());
|
||||
Coordinate2D<double> pointOfInterest = computeNewPointOfInteresetFromAbscissa(m_graphRange->xMin(), 1);
|
||||
if (std::isnan(pointOfInterest.abscissa())) {
|
||||
if (std::isnan(pointOfInterest.x())) {
|
||||
m_isActive = false;
|
||||
m_graphView->setCursorView(nullptr);
|
||||
m_graphView->setBannerView(&m_defaultBannerView);
|
||||
} else {
|
||||
m_isActive = true;
|
||||
m_cursor->moveTo(pointOfInterest.abscissa(), pointOfInterest.value());
|
||||
m_cursor->moveTo(pointOfInterest.x(), pointOfInterest.y());
|
||||
m_graphRange->panToMakePointVisible(m_cursor->x(), m_cursor->y(), cursorTopMarginRatio(), k_cursorRightMarginRatio, cursorBottomMarginRatio(), k_cursorLeftMarginRatio);
|
||||
m_bannerView->setNumberOfSubviews(Shared::XYBannerView::k_numberOfSubviews);
|
||||
reloadBannerView();
|
||||
@@ -70,10 +70,10 @@ bool CalculationGraphController::handleEnter() {
|
||||
|
||||
bool CalculationGraphController::moveCursorHorizontally(int direction) {
|
||||
Coordinate2D<double> newPointOfInterest = computeNewPointOfInteresetFromAbscissa(m_cursor->x(), direction);
|
||||
if (std::isnan(newPointOfInterest.abscissa())) {
|
||||
if (std::isnan(newPointOfInterest.x())) {
|
||||
return false;
|
||||
}
|
||||
m_cursor->moveTo(newPointOfInterest.abscissa(), newPointOfInterest.value());
|
||||
m_cursor->moveTo(newPointOfInterest.x(), newPointOfInterest.y());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,9 +51,9 @@ Poincare::Coordinate2D<double> IntersectionGraphController::computeNewPointOfInt
|
||||
if (record != m_record) {
|
||||
Poincare::Expression e = functionStore()->modelForRecord(record)->expressionReduced(context);
|
||||
Poincare::Coordinate2D<double> intersection = Shared::PoincareHelpers::NextIntersection(functionStore()->modelForRecord(m_record)->expressionReduced(context), unknownX, start, step, max, context, e);
|
||||
if ((std::isnan(result.abscissa()) || std::fabs(intersection.abscissa()-start) < std::fabs(result.abscissa()-start)) && !std::isnan(intersection.abscissa())) {
|
||||
if ((std::isnan(result.x()) || std::fabs(intersection.x()-start) < std::fabs(result.x()-start)) && !std::isnan(intersection.x())) {
|
||||
m_intersectedRecord = record;
|
||||
result = (std::isnan(result.abscissa()) || std::fabs(intersection.abscissa()-start) < std::fabs(result.abscissa()-start)) ? intersection : result;
|
||||
result = (std::isnan(result.x()) || std::fabs(intersection.x()-start) < std::fabs(result.x()-start)) ? intersection : result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,8 +126,8 @@ double Distribution::cumulativeDistributiveInverseForProbabilityUsingIncreasingF
|
||||
this,
|
||||
probability,
|
||||
nullptr);
|
||||
assert(std::isnan(result.value()) || std::fabs(result.value()) < FLT_EPSILON);
|
||||
return result.abscissa();
|
||||
assert(std::isnan(result.y()) || std::fabs(result.y()) < FLT_EPSILON);
|
||||
return result.x();
|
||||
}
|
||||
|
||||
float Distribution::yMin() const {
|
||||
|
||||
@@ -27,7 +27,7 @@ double Model::levelSet(double * modelCoefficients, double xMin, double step, dou
|
||||
Expression yExpression = Number::DecimalNumber(y);
|
||||
PoincareHelpers::Simplify(&yExpression, context);
|
||||
Expression modelExpression = simplifiedExpression(modelCoefficients, context);
|
||||
double result = PoincareHelpers::NextIntersection(modelExpression, "x", xMin, step, xMax, context, yExpression).abscissa();
|
||||
double result = PoincareHelpers::NextIntersection(modelExpression, "x", xMin, step, xMax, context, yExpression).x();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,14 +8,14 @@ namespace Poincare {
|
||||
template <typename T>
|
||||
class Coordinate2D final {
|
||||
public:
|
||||
Coordinate2D(T abscissa = NAN, T value = NAN) : m_abscissa(abscissa), m_value(value) {}
|
||||
T abscissa() const { return m_abscissa; }
|
||||
T value() const { return m_value; }
|
||||
void setAbscissa(T a) { m_abscissa = a; }
|
||||
void setValue(T v) { m_value = v; }
|
||||
Coordinate2D(T x = NAN, T y = NAN) : m_x(x), m_y(y) {}
|
||||
T x() const { return m_x; }
|
||||
T y() const { return m_y; }
|
||||
void setX(T x) { m_x = x; }
|
||||
void setY(T y) { m_y = y; }
|
||||
private:
|
||||
T m_abscissa;
|
||||
T m_value;
|
||||
T m_x;
|
||||
T m_y;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -889,7 +889,7 @@ Coordinate2D<double> Expression::nextMaximum(const char * symbol, double start,
|
||||
const char * symbol = reinterpret_cast<const char *>(context2);
|
||||
return -expression0->approximateWithValueForSymbol(symbol, x, context, complexFormat, angleUnit);
|
||||
}, context, complexFormat, angleUnit);
|
||||
return Coordinate2D<double>(minimumOfOpposite.abscissa(), -minimumOfOpposite.value());
|
||||
return Coordinate2D<double>(minimumOfOpposite.x(), -minimumOfOpposite.y());
|
||||
}
|
||||
|
||||
double Expression::nextRoot(const char * symbol, double start, double step, double max, Context * context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit) const {
|
||||
@@ -910,8 +910,8 @@ Coordinate2D<double> Expression::nextIntersection(const char * symbol, double st
|
||||
return expression0->approximateWithValueForSymbol(symbol, x, context, complexFormat, angleUnit)-expression1->approximateWithValueForSymbol(symbol, x, context, complexFormat, angleUnit);
|
||||
}, context, complexFormat, angleUnit, expression);
|
||||
Coordinate2D<double> result(resultAbscissa, approximateWithValueForSymbol(symbol, resultAbscissa, context, complexFormat, angleUnit));
|
||||
if (std::fabs(result.value()) < step*k_solverPrecision) {
|
||||
result.setValue(0.0);
|
||||
if (std::fabs(result.y()) < step*k_solverPrecision) {
|
||||
result.setY(0.0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -929,26 +929,26 @@ Coordinate2D<double> Expression::nextMinimumOfExpression(const char * symbol, do
|
||||
result = brentMinimum(symbol, bracket[0], bracket[2], evaluate, context, complexFormat, angleUnit, expression);
|
||||
x = bracket[1];
|
||||
// Because of float approximation, exact zero is never reached
|
||||
if (std::fabs(result.abscissa()) < std::fabs(step)*k_solverPrecision) {
|
||||
result.setAbscissa(0);
|
||||
result.setValue(evaluate(0, context, complexFormat, angleUnit, this, symbol, &expression));
|
||||
if (std::fabs(result.x()) < std::fabs(step)*k_solverPrecision) {
|
||||
result.setX(0);
|
||||
result.setY(evaluate(0, context, complexFormat, angleUnit, this, symbol, &expression));
|
||||
}
|
||||
/* Ignore extremum whose value is undefined or too big because they are
|
||||
* really unlikely to be local extremum. */
|
||||
if (std::isnan(result.value()) || std::fabs(result.value()) > k_maxFloat) {
|
||||
result.setAbscissa(NAN);
|
||||
if (std::isnan(result.y()) || std::fabs(result.y()) > k_maxFloat) {
|
||||
result.setX(NAN);
|
||||
}
|
||||
// Idem, exact 0 never reached
|
||||
if (std::fabs(result.value()) < std::fabs(step)*k_solverPrecision) {
|
||||
result.setValue(0);
|
||||
if (std::fabs(result.y()) < std::fabs(step)*k_solverPrecision) {
|
||||
result.setY(0);
|
||||
}
|
||||
endCondition = std::isnan(result.abscissa()) && (step > 0.0 ? x <= max : x >= max);
|
||||
endCondition = std::isnan(result.x()) && (step > 0.0 ? x <= max : x >= max);
|
||||
if (lookForRootMinimum) {
|
||||
endCondition |= std::fabs(result.value()) > 0 && (step > 0.0 ? x <= max : x >= max);
|
||||
endCondition |= std::fabs(result.y()) > 0 && (step > 0.0 ? x <= max : x >= max);
|
||||
}
|
||||
} while (endCondition);
|
||||
if (lookForRootMinimum && std::fabs(result.value()) > 0) {
|
||||
result.setAbscissa(NAN);
|
||||
if (lookForRootMinimum && std::fabs(result.y()) > 0) {
|
||||
result.setX(NAN);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -961,18 +961,18 @@ void Expression::bracketMinimum(const char * symbol, double start, double step,
|
||||
};
|
||||
double x = start+2.0*step;
|
||||
while (step > 0.0 ? x <= max : x >= max) {
|
||||
p[2].setAbscissa(x);
|
||||
p[2].setValue(evaluate(x, context, complexFormat, angleUnit, this, symbol, &expression));
|
||||
if ((p[0].value() > p[1].value() || std::isnan(p[0].value()))
|
||||
&& (p[2].value() > p[1].value() || std::isnan(p[2].value()))
|
||||
&& (!std::isnan(p[0].value()) || !std::isnan(p[2].value())))
|
||||
p[2].setX(x);
|
||||
p[2].setY(evaluate(x, context, complexFormat, angleUnit, this, symbol, &expression));
|
||||
if ((p[0].y() > p[1].y() || std::isnan(p[0].y()))
|
||||
&& (p[2].y() > p[1].y() || std::isnan(p[2].y()))
|
||||
&& (!std::isnan(p[0].y()) || !std::isnan(p[2].y())))
|
||||
{
|
||||
result[0] = p[0].abscissa();
|
||||
result[1] = p[1].abscissa();
|
||||
result[2] = p[2].abscissa();
|
||||
result[0] = p[0].x();
|
||||
result[1] = p[1].x();
|
||||
result[2] = p[2].x();
|
||||
return;
|
||||
}
|
||||
if (p[0].value() > p[1].value() && p[1].value() == p[2].value()) {
|
||||
if (p[0].y() > p[1].y() && p[1].y() == p[2].y()) {
|
||||
} else {
|
||||
p[0] = p[1];
|
||||
p[1] = p[2];
|
||||
@@ -1028,8 +1028,8 @@ double Expression::nextIntersectionWithExpression(const char * symbol, double st
|
||||
return (expression1->isUninitialized() ? 0.0 : expression1->approximateWithValueForSymbol(symbol, x, context, complexFormat, angleUnit)) - expression0->approximateWithValueForSymbol(symbol, x, context, complexFormat, angleUnit);
|
||||
}, context, complexFormat, angleUnit, expression, true)};
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (!std::isnan(resultExtremum[i].abscissa()) && (std::isnan(result) || std::fabs(result - start) > std::fabs(resultExtremum[i].abscissa() - start))) {
|
||||
result = resultExtremum[i].abscissa();
|
||||
if (!std::isnan(resultExtremum[i].x()) && (std::isnan(result) || std::fabs(result - start) > std::fabs(resultExtremum[i].x() - start))) {
|
||||
result = resultExtremum[i].x();
|
||||
}
|
||||
}
|
||||
if (std::fabs(result) < std::fabs(step)*k_solverPrecision) {
|
||||
|
||||
@@ -45,10 +45,10 @@ void assert_next_extrema_are(
|
||||
} else if (extremumType == ExtremumType::Root) {
|
||||
nextExtrema = Coordinate2D<double>(e.nextRoot(symbol, currentStart, step, max, context, complexFormat, angleUnit), 0.0 );
|
||||
}
|
||||
currentStart = nextExtrema.abscissa() + step;
|
||||
currentStart = nextExtrema.x() + step;
|
||||
quiz_assert_log_if_failure(
|
||||
(doubles_are_approximately_equal(extrema[i].abscissa(), nextExtrema.abscissa()))
|
||||
&& (doubles_are_approximately_equal(extrema[i].value(), nextExtrema.value())),
|
||||
(doubles_are_approximately_equal(extrema[i].x(), nextExtrema.x()))
|
||||
&& (doubles_are_approximately_equal(extrema[i].y(), nextExtrema.y())),
|
||||
e);
|
||||
}
|
||||
}
|
||||
@@ -195,10 +195,10 @@ void assert_next_intersections_are(
|
||||
for (int i = 0; i < numberOfIntersections; i++) {
|
||||
quiz_assert_log_if_failure(!std::isnan(currentStart), e);
|
||||
Coordinate2D<double> nextIntersection = e.nextIntersection(symbol, currentStart, step, max, context, complexFormat, angleUnit, otherExpression);
|
||||
currentStart = nextIntersection.abscissa() + step;
|
||||
currentStart = nextIntersection.x() + step;
|
||||
quiz_assert_log_if_failure(
|
||||
(doubles_are_approximately_equal(intersections[i].abscissa(), nextIntersection.abscissa()))
|
||||
&& (doubles_are_approximately_equal(intersections[i].value(), nextIntersection.value())),
|
||||
(doubles_are_approximately_equal(intersections[i].x(), nextIntersection.x()))
|
||||
&& (doubles_are_approximately_equal(intersections[i].y(), nextIntersection.y())),
|
||||
e);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user