Skip to content

Commit

Permalink
Removing unneeded code and unnecessary include statements.
Browse files Browse the repository at this point in the history
  • Loading branch information
joeykleingers committed Feb 21, 2017
1 parent 8ac6b0e commit 7e35449
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 223 deletions.
215 changes: 0 additions & 215 deletions Source/OrientationLib/OrientationMath/OrientationMath.cpp
Expand Up @@ -37,107 +37,6 @@

#include <cmath>

#include "SIMPLib/Math/SIMPLibMath.h"
#include "SIMPLib/Math/MatrixMath.h"
#include "SIMPLib/Math/GeometryMath.h"

#include "OrientationLib/OrientationMath/OrientationTransforms.hpp"
#include "OrientationLib/LaueOps/CubicOps.h"
#include "OrientationLib/LaueOps/HexagonalOps.h"
#include "OrientationLib/LaueOps/OrthoRhombicOps.h"
#include "OrientationLib/LaueOps/TrigonalOps.h"
#include "OrientationLib/LaueOps/TetragonalOps.h"


#define ASSERT(condition, message) \
do { \
if (! (condition)) { \
std::cerr << "Assertion `" #condition "` failed in " << __FILE__ \
<< " line " << __LINE__ << ": " << message << std::endl; \
std::exit(EXIT_FAILURE); \
} \
} while (false)


// Floating-point modulo
// The result (the remainder) has same sign as the divisor.
// Similar to matlab's mod(); Not similar to fmod() - Mod(-3,4)= 1 fmod(-3,4)= -3
template<typename T>
class Mod
{
public:
Mod() {}
virtual ~Mod() {}

T operator()(T x, T y)
{
ASSERT(!std::numeric_limits<T>::is_exact , "Mod: floating-point type expected");

if (0. == y)
{ return x; }

double m = x - y * floor(x / y);

// handle boundary cases resulted from floating-point cut off:

if (y > 0) // modulo range: [0..y)
{
if (m >= y) // Mod(-1e-16 , 360. ): m= 360.
{ return 0; }

if (m < 0 )
{
if (y + m == y)
{ return 0 ; } // just in case...
else
{ return y + m; } // Mod(106.81415022205296 , _TWO_PI ): m= -1.421e-14
}
}
else // modulo range: (y..0]
{
if (m <= y) // Mod(1e-16 , -360. ): m= -360.
{ return 0; }

if (m > 0 )
{
if (y + m == y)
{ return 0 ; } // just in case...
else
{ return y + m; } // Mod(-106.81415022205296, -_TWO_PI): m= 1.421e-14
}
}

return m;
}

// wrap [rad] angle to [-PI..PI)
inline static T WrapPosNegPI(T fAng)
{
return Mod()(fAng + SIMPLib::Constants::k_Pi, SIMPLib::Constants::k_2Pi) - SIMPLib::Constants::k_Pi;
}

// wrap [rad] angle to [0..TWO_PI)
inline T WrapTwoPI(T fAng)
{
return Mod()(fAng, SIMPLib::Constants::k_2Pi);
}

// wrap [deg] angle to [-180..180)
inline T WrapPosNeg180(T fAng)
{
return Mod()(fAng + 180.0, 360.0) - 180.0;
}

// wrap [deg] angle to [0..360)
inline T Wrap360(T fAng)
{
return Mod()(fAng , 360.0);
}

private:
Mod(const Mod&); // Copy Constructor Not Implemented
void operator=(const Mod&); // Operator '=' Not Implemented
};
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
Expand All @@ -152,120 +51,6 @@ OrientationMath::~OrientationMath()
{
}

#if 0

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void OrientationMath::EulertoMatActive(float ea1, float ea2, float ea3, float g[3][3])
{
// Calcuate all the values once
float cp1 = cosf(ea1);
float sp1 = sinf(ea1);
float cp = cosf(ea2);
float sp = sinf(ea2);
float cp2 = cosf(ea3);
float sp2 = sinf(ea3);

// 1) find rotation matrix from Euler angles
// g[row][col] This is an ACTIVE rotation
g[0][0] = cp1 * cp2 - sp1 * sp2 * cp;
g[0][1] = -cp1 * sp2 - sp1 * cp2 * cp;
g[0][2] = sp1 * sp;
g[1][0] = sp1 * cp2 + cp1 * sp2 * cp;
g[1][1] = -sp1 * sp2 + cp1 * cp2 * cp;
g[1][2] = -cp1 * sp;
g[2][0] = sp2 * sp;
g[2][1] = cp2 * sp;
g[2][2] = cp;
}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
float OrientationMath::MatrixMisorientation(float g1[3][3], float g2[3][3])
{
float deltaG[3][3];
//only need to calculate diagonal terms to allow for trace calculation
deltaG[0][0] = g1[0][0] * g2[0][0] + g1[1][0] * g2[1][0] + g1[2][0] * g2[2][0];
deltaG[1][1] = g1[0][1] * g2[0][1] + g1[1][1] * g2[1][1] + g1[2][1] * g2[2][1];
deltaG[2][2] = g1[0][2] * g2[0][2] + g1[1][2] * g2[1][2] + g1[2][2] * g2[2][2];
float value = 0.5 * ((deltaG[0][0] + deltaG[1][1] + deltaG[2][2]) - 1.0);
if(value > 1.0)
{
value = 1.0;
}
if(value < -1.0)
{
value = -1.0;
}
return acosf(value);
}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void OrientationMath::ChangeAxisReferenceFrame(QuatF& q, float& n1, float& n2, float& n3)
{
float g[3][3];
float n[3];
float nNew[3];

n[0] = n1;
n[1] = n2;
n[2] = n3;

FOrientArrayType om(9, 0.0f);
FOrientTransformsType::qu2om(FOrientArrayType(q), om);
om.toGMatrix(g);

MatrixMath::Multiply3x3with3x1(g, n, nNew);
MatrixMath::Normalize3x1(nNew);
n1 = nNew[0];
n2 = nNew[1];
n3 = nNew[2];
}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
QuatF OrientationMath::PassiveRotation(float angle, float xAxis, float yAxis, float zAxis, float x, float y, float z)
{
QuatF q;
QuatF qStar;

FOrientArrayType quat(4);
FOrientTransformsType::ax2qu(FOrientArrayType(xAxis, yAxis, zAxis, angle), quat);
q = quat.toQuaternion();

QuaternionMathF::Conjugate(q, qStar);
QuatF v = QuaternionMathF::New(x, y, z, 0); // Make the Pure quaternion

QuatF temp = QuaternionMathF::Multiply(qStar, v);
QuatF passive = QuaternionMathF::Multiply(temp, q);
return passive;
}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
QuatF OrientationMath::ActiveRotation(float angle, float xAxis, float yAxis, float zAxis, float x, float y, float z)
{
QuatF q;
QuatF qStar;
FOrientArrayType quat(4);
FOrientTransformsType::ax2qu(FOrientArrayType(xAxis, yAxis, zAxis, angle), quat);
q = quat.toQuaternion();

QuaternionMathF::Conjugate(q, qStar);
QuatF v = QuaternionMathF::New(x, y, z, 0); // Make the Pure quaternion

QuatF temp = QuaternionMathF::Multiply(q, v);
QuatF active = QuaternionMathF::Multiply(temp, qStar);
return active;
}
#endif

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
Expand Down
Expand Up @@ -47,21 +47,13 @@
#include <Accelerate/Accelerate.h>
#endif


#include <Eigen/Core>
#include <Eigen/Dense>
#include <Eigen/Eigen>


#include "SIMPLib/SIMPLib.h"
#include "SIMPLib/Math/SIMPLibMath.h"
#include "SIMPLib/Math/MatrixMath.h"
#include "SIMPLib/Math/QuaternionMath.hpp"
#include "SIMPLib/Math/ArrayHelpers.hpp"


#include "OrientationLib/OrientationLib.h"
#include "OrientationLib/OrientationLibConstants.h"
#include "OrientationLib/OrientationMath/OrientationArray.hpp"
#include "OrientationLib/Utilities/ModifiedLambertProjection3D.hpp"

Expand Down

0 comments on commit 7e35449

Please sign in to comment.