Initial refactoring of vector and matrix classes

This commit is contained in:
Klaus Basan
2013-04-18 01:04:21 +02:00
parent 5f678dfe28
commit 5bf308c54b
34 changed files with 2004 additions and 40 deletions

View File

@@ -0,0 +1,38 @@
/* Copyright (C) 2013 VATSIM Community / authors
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "blackmisc/mathematics.h"
#include <algorithm> // std::max
namespace BlackMisc
{
namespace Math
{
/*
* Hypotenuse
*/
double CMath::hypot(double x, double y)
{
x = abs(x);
y = abs(y);
double max = std::max(x, y);
double min = std::min(x, y);
double r = min / max;
return max * sqrt(1 + r * r);
}
/*
* Real part of cubic root
*/
double CMath::cubicRootReal(const double x)
{
double result;
result = std::pow(std::abs(x), (double)1 / 3);
return x < 0 ? -result : result;
}
} // namespace
} // namespace