-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgridproperties.cpp
More file actions
18 lines (14 loc) · 723 Bytes
/
gridproperties.cpp
File metadata and controls
18 lines (14 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// SPDX-FileCopyrightText: 2017 Christian Sailer
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "gridproperties.hpp"
#include <cmath>
GridProperties::GridProperties(double maxDimension) : m_max(), m_min(), m_default() {
int maxexponent = static_cast<int>(floor(log10(maxDimension)) - 1);
int minexponent = maxexponent - 2;
int mantissa =
static_cast<int>(floor(maxDimension / pow(10.0, static_cast<double>(maxexponent + 1))));
m_default = static_cast<double>(mantissa) * pow(10.0, static_cast<double>(maxexponent - 1));
m_max = 2.0 * mantissa * pow(10.0, static_cast<double>(maxexponent));
m_min = static_cast<double>(mantissa) * pow(10.0, static_cast<double>(minexponent));
}