summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2013-09-15 03:51:42 +0200
committerStanislaw Halik <sthalik@misaki.pl>2013-09-15 03:51:42 +0200
commitec228053011db8a2d265e39ed0ba2ce240177d17 (patch)
treec6e7a931a8593b97fa2af29de659e68fd23fda77
parente1cf876626aad4cbed2db96f30867c8e11af340e (diff)
Use double precision for intermediate computation
-rw-r--r--qfunctionconfigurator/functionconfig.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp
index 5dab2b52..6e1569f9 100644
--- a/qfunctionconfigurator/functionconfig.cpp
+++ b/qfunctionconfigurator/functionconfig.cpp
@@ -138,20 +138,20 @@ void FunctionConfig::reload() {
int start = p1.x() * MEMOIZE_PRECISION;
for (int j = start; j < end && j < _size; j++) {
- float t = (j - start) / (float) (end - start);
- float t2 = t*t;
- float t3 = t*t*t;
+ double t = (j - start) / (double) (end - start);
+ double t2 = t*t;
+ double t3 = t*t*t;
- int x = .5 * ((2 * p1.x()) +
+ int x = .5 * ((2. * p1.x()) +
(-p0.x() + p2.x()) * t +
- (2 * p0.x() - 5 * p1.x() + 4 * p2.x() - p3.x()) * t2 +
- (-p0.x() + 3 * p1.x() - 3 * p2.x() + p3.x()) * t3)
+ (2. * p0.x() - 5. * p1.x() + 4. * p2.x() - p3.x()) * t2 +
+ (-p0.x() + 3. * p1.x() - 3. * p2.x() + p3.x()) * t3)
* MEMOIZE_PRECISION;
- float y = .5 * ((2 * p1.y()) +
+ float y = .5 * ((2. * p1.y()) +
(-p0.y() + p2.y()) * t +
- (2 * p0.y() - 5 * p1.y() + 4 * p2.y() - p3.y()) * t2 +
- (-p0.y() + 3 * p1.y() - 3 * p2.y() + p3.y()) * t3);
+ (2. * p0.y() - 5. * p1.y() + 4. * p2.y() - p3.y()) * t2 +
+ (-p0.y() + 3. * p1.y() - 3. * p2.y() + p3.y()) * t3);
if (x >= 0 && x < _size)
_data[x] = y;