* @brief Computes a clean grid step based on current world scale. */
| 792 | * @brief Computes a clean grid step based on current world scale. |
| 793 | */ |
| 794 | double Widgets::Plot3D::gridStep(const double scale) const |
| 795 | { |
| 796 | auto s = scale; |
| 797 | if (s == -1) |
| 798 | s = m_worldScale; |
| 799 | |
| 800 | const float rawStep = 1.0f / s; |
| 801 | const float exponent = std::floor(std::log10(rawStep)); |
| 802 | const float base = static_cast<float>(fastPow10(exponent)); |
| 803 | |
| 804 | if (rawStep >= base * 5) |
| 805 | return base * 5; |
| 806 | else if (rawStep >= base * 2) |
| 807 | return base * 2; |
| 808 | else |
| 809 | return base; |
| 810 | } |
| 811 | |
| 812 | /** |
| 813 | * @brief Projects 3D world-space points into 2D screen-space coordinates. |