[libaxx] add cmath and use cmath instead of math.h when required

Change-Id: Id839b17d33c69e2e002f370e553ff35246a1bc90
This commit is contained in:
Émilie Feral
2017-08-07 11:47:47 +02:00
parent 9f0bbe0e75
commit 1964d61fdc
111 changed files with 377 additions and 303 deletions

View File

@@ -1,7 +1,7 @@
#include "interactive_curve_view_range.h"
#include <poincare.h>
#include <ion.h>
#include <math.h>
#include <cmath>
#include <stddef.h>
#include <assert.h>
@@ -90,7 +90,7 @@ void InteractiveCurveViewRange::zoom(float ratio, float x, float y) {
float xMax = m_xMax;
float yMin = m_yMin;
float yMax = m_yMax;
if (ratio*fabsf(xMax-xMin) < k_minFloat || ratio*fabsf(yMax-yMin) < k_minFloat) {
if (ratio*std::fabs(xMax-xMin) < k_minFloat || ratio*std::fabs(yMax-yMin) < k_minFloat) {
return;
}
float newXMin = clipped(x*(1.0f-ratio)+ratio*xMin, false);
@@ -122,8 +122,8 @@ void InteractiveCurveViewRange::panWithVector(float x, float y) {
void InteractiveCurveViewRange::roundAbscissa() {
float xMin = m_xMin;
float xMax = m_xMax;
float newXMin = clipped(roundf((xMin+xMax)/2) - (float)Ion::Display::Width/2.0f, false);
float newXMax = clipped(roundf((xMin+xMax)/2) + (float)Ion::Display::Width/2.0f-1.0f, true);
float newXMin = clipped(std::round((xMin+xMax)/2) - (float)Ion::Display::Width/2.0f, false);
float newXMax = clipped(std::round((xMin+xMax)/2) + (float)Ion::Display::Width/2.0f-1.0f, true);
if (isnan(newXMin) || isnan(newXMax)) {
return;
}
@@ -178,16 +178,16 @@ void InteractiveCurveViewRange::centerAxisAround(Axis axis, float position) {
}
if (axis == Axis::X) {
float range = m_xMax - m_xMin;
if (fabsf(position/range) > k_maxRatioPositionRange) {
range = powf(10.0f, floorf(log10f(fabsf(position)))-1.0f);
if (std::fabs(position/range) > k_maxRatioPositionRange) {
range = std::pow(10.0f, std::floor(std::log10(std::fabs(position)))-1.0f);
}
m_xMax = clipped(position + range/2.0f, true);
MemoizedCurveViewRange::setXMin(clipped(position - range/2.0f, false));
} else {
m_yAuto = false;
float range = m_yMax - m_yMin;
if (fabsf(position/range) > k_maxRatioPositionRange) {
range = powf(10.0f, floorf(log10f(fabsf(position)))-1.0f);
if (std::fabs(position/range) > k_maxRatioPositionRange) {
range = std::pow(10.0f, std::floor(std::log10(std::fabs(position)))-1.0f);
}
m_yMax = clipped(position + range/2.0f, true);
MemoizedCurveViewRange::setYMin(clipped(position - range/2.0f, false));