Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,8 @@ set(SIMPLNX_HDRS
${SIMPLNX_SOURCE_DIR}/Common/Types.hpp
${SIMPLNX_SOURCE_DIR}/Common/TypesUtility.hpp
${SIMPLNX_SOURCE_DIR}/Common/Uuid.hpp
${SIMPLNX_SOURCE_DIR}/Common/Matrix3X3.hpp
${SIMPLNX_SOURCE_DIR}/Common/Matrix3X1.hpp

${SIMPLNX_SOURCE_DIR}/Core/Application.hpp
${SIMPLNX_SOURCE_DIR}/Core/Preferences.hpp
Expand Down Expand Up @@ -575,7 +577,7 @@ set(SIMPLNX_HDRS
${SIMPLNX_SOURCE_DIR}/Utilities/NeighborUtilities.hpp

${SIMPLNX_SOURCE_DIR}/Utilities/Math/GeometryMath.hpp
${SIMPLNX_SOURCE_DIR}/Utilities/Math/MatrixMath.hpp
# ${SIMPLNX_SOURCE_DIR}/Utilities/Math/MatrixMath.hpp
${SIMPLNX_SOURCE_DIR}/Utilities/Math/StatisticsCalculations.hpp

${SIMPLNX_SOURCE_DIR}/Utilities/Meshing/VertexUtilities.hpp
Expand Down Expand Up @@ -769,7 +771,7 @@ set(SIMPLNX_SRCS
${SIMPLNX_SOURCE_DIR}/Utilities/ColorTableUtilities.cpp
${SIMPLNX_SOURCE_DIR}/Utilities/ImageRotationUtilities.cpp
${SIMPLNX_SOURCE_DIR}/Utilities/Math/GeometryMath.cpp
${SIMPLNX_SOURCE_DIR}/Utilities/Math/MatrixMath.cpp
#${SIMPLNX_SOURCE_DIR}/Utilities/Math/MatrixMath.cpp
${SIMPLNX_SOURCE_DIR}/Utilities/SampleSurfaceMesh.cpp
${SIMPLNX_SOURCE_DIR}/Utilities/MontageUtilities.cpp
${SIMPLNX_SOURCE_DIR}/Utilities/TimeUtilities.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "simplnx/DataStructure/DataArray.hpp"
#include "simplnx/DataStructure/Geometry/ImageGeom.hpp"
#include "simplnx/Utilities/ClusteringUtilities.hpp"
#include "simplnx/Utilities/Math/MatrixMath.hpp"

#include <EbsdLib/Orientation/OrientationFwd.hpp>
#include <EbsdLib/Orientation/OrientationMatrix.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "simplnx/DataStructure/DataArray.hpp"
#include "simplnx/Utilities/ImageRotationUtilities.hpp"
#include "simplnx/Utilities/Math/GeometryMath.hpp"
#include "simplnx/Utilities/Math/MatrixMath.hpp"

#include <EbsdLib/Core/Orientation.hpp>
#include <EbsdLib/Orientation/OrientationFwd.hpp>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "ComputeBoundaryStrengths.hpp"

#include "simplnx/Common/Array.hpp"
#include "simplnx/DataStructure/DataArray.hpp"
#include "simplnx/DataStructure/DataGroup.hpp"
#include "simplnx/Utilities/Math/MatrixMath.hpp"

#include <EbsdLib/LaueOps/LaueOps.h>
#include <EbsdLib/Orientation/Quaternion.hpp>
Expand Down Expand Up @@ -48,8 +48,9 @@ Result<> ComputeBoundaryStrengths::operator()()
float32 mPrime_1, mPrime_2, F1_1, F1_2, F1spt_1, F1spt_2, F7_1, F7_2;
int32 gName1, gName2;

float64 LD[3] = {m_InputValues->Loading[0], m_InputValues->Loading[1], m_InputValues->Loading[2]};
MatrixMath::Normalize3x1(LD);
nx::core::Vec3<float64> LD = {m_InputValues->Loading[0], m_InputValues->Loading[1], m_InputValues->Loading[2]};
LD = LD.normalize();

bool emitLaueClassWarning = false;

for(usize i = 0; i < numTriangles; i++)
Expand All @@ -70,14 +71,14 @@ Result<> ComputeBoundaryStrengths::operator()()
if(crystalStructures[laueClassG1] == crystalStructures[laueClassG2] && featurePhases[gName1] > 0)
{
ebsdlib::LaueOps::Pointer laueClass = orientationOps[crystalStructures[featurePhases[gName1]]];
mPrime_1 = static_cast<float32>(laueClass->getmPrime(q1, q2, LD));
mPrime_2 = static_cast<float32>(laueClass->getmPrime(q2, q1, LD));
F1_1 = static_cast<float32>(laueClass->getF1(q1, q2, LD, true));
F1_2 = static_cast<float32>(laueClass->getF1(q2, q1, LD, true));
F1spt_1 = static_cast<float32>(laueClass->getF1spt(q1, q2, LD, true));
F1spt_2 = static_cast<float32>(laueClass->getF1spt(q2, q1, LD, true));
F7_1 = static_cast<float32>(laueClass->getF7(q1, q2, LD, true));
F7_2 = static_cast<float32>(laueClass->getF7(q2, q1, LD, true));
mPrime_1 = static_cast<float32>(laueClass->getmPrime(q1, q2, LD.data()));
mPrime_2 = static_cast<float32>(laueClass->getmPrime(q2, q1, LD.data()));
F1_1 = static_cast<float32>(laueClass->getF1(q1, q2, LD.data(), true));
F1_2 = static_cast<float32>(laueClass->getF1(q2, q1, LD.data(), true));
F1spt_1 = static_cast<float32>(laueClass->getF1spt(q1, q2, LD.data(), true));
F1spt_2 = static_cast<float32>(laueClass->getF1spt(q2, q1, LD.data(), true));
F7_1 = static_cast<float32>(laueClass->getF7(q1, q2, LD.data(), true));
F7_2 = static_cast<float32>(laueClass->getF7(q2, q1, LD.data(), true));
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "simplnx/Common/Constants.hpp"
#include "simplnx/DataStructure/DataArray.hpp"
#include "simplnx/DataStructure/DataGroup.hpp"
#include "simplnx/Utilities/Math/MatrixMath.hpp"
#include "simplnx/Utilities/MessageHelper.hpp"
#include "simplnx/Utilities/ParallelDataAlgorithm.hpp"
#include "simplnx/Utilities/TimeUtilities.hpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#include "ComputeGBCDPoleFigure.hpp"

#include "simplnx/Common/Bit.hpp"
#include "simplnx/Common/Array.hpp"
#include "simplnx/Common/Constants.hpp"
#include "simplnx/DataStructure/DataArray.hpp"
#include "simplnx/Utilities/Math/MatrixMath.hpp"
#include "simplnx/Utilities/ParallelData2DAlgorithm.hpp"

#include <EbsdLib/Core/Orientation.hpp>
Expand Down Expand Up @@ -63,8 +62,8 @@ class ComputeGBCDPoleFigureImpl
// Matrix3X1<float> misEuler1 = {0.0f, 0.0f, 0.0f};

float32 misAngle = m_MisorientationRotation[0] * nx::core::Constants::k_PiOver180F;
float32 normAxis[3] = {m_MisorientationRotation[1], m_MisorientationRotation[2], m_MisorientationRotation[3]};
MatrixMath::Normalize3x1(normAxis);
nx::core::FloatVec3 normAxis = {m_MisorientationRotation[1], m_MisorientationRotation[2], m_MisorientationRotation[3]};
normAxis = normAxis.normalize();
// convert axis angle to matrix representation of misorientation
ebsdlib::Matrix3X3<float> dg = ebsdlib::AxisAngleFType(normAxis[0], normAxis[1], normAxis[2], misAngle).toOrientationMatrix().toGMatrix();
// take inverse of misorientation variable to use for switching symmetry
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
#include "ComputeIPFColors.hpp"

#include "simplnx/Common/Array.hpp"
#include "simplnx/Common/RgbColor.hpp"
#include "simplnx/DataStructure/DataArray.hpp"
#include "simplnx/DataStructure/DataStore.hpp"
#include "simplnx/Utilities/Math/MatrixMath.hpp"
#include "simplnx/Utilities/ParallelDataAlgorithm.hpp"

#include <EbsdLib/LaueOps/LaueOps.h>
#include <EbsdLib/Orientation/OrientationFwd.hpp>

using namespace nx::core;

using FloatVec3Type = std::vector<float>;

namespace
{

Expand All @@ -23,8 +21,8 @@ namespace
class ComputeIPFColorsImpl
{
public:
ComputeIPFColorsImpl(ComputeIPFColors* filter, FloatVec3Type referenceDir, nx::core::Float32Array& eulers, nx::core::Int32Array& phases, nx::core::UInt32Array& crystalStructures, int32_t numPhases,
const nx::core::IDataArray* goodVoxels, nx::core::UInt8Array& colors)
ComputeIPFColorsImpl(ComputeIPFColors* filter, nx::core::FloatVec3 referenceDir, nx::core::Float32Array& eulers, nx::core::Int32Array& phases, nx::core::UInt32Array& crystalStructures,
int32_t numPhases, const nx::core::IDataArray* goodVoxels, nx::core::UInt8Array& colors)
: m_Filter(filter)
, m_ReferenceDir(referenceDir)
, m_CellEulerAngles(eulers.getDataStoreRef())
Expand Down Expand Up @@ -118,7 +116,7 @@ class ComputeIPFColorsImpl

private:
ComputeIPFColors* m_Filter = nullptr;
FloatVec3Type m_ReferenceDir;
nx::core::FloatVec3 m_ReferenceDir;
nx::core::Float32AbstractDataStore& m_CellEulerAngles;
nx::core::Int32AbstractDataStore& m_CellPhases;
nx::core::UInt32AbstractDataStore& m_CrystalStructures;
Expand Down Expand Up @@ -159,9 +157,8 @@ Result<> ComputeIPFColors::operator()()
int32_t numPhases = static_cast<int32_t>(crystalStructures.getNumberOfTuples());

// Make sure we are dealing with a unit 1 vector.
FloatVec3Type normRefDir = m_InputValues->referenceDirection; // Make a copy of the reference Direction

MatrixMath::Normalize3x1(normRefDir[0], normRefDir[1], normRefDir[2]);
nx::core::FloatVec3 normRefDir = m_InputValues->referenceDirection; // Make a copy of the reference Direction
normRefDir = normRefDir.normalize();

typename IParallelAlgorithm::AlgorithmArrays algArrays;
algArrays.push_back(&eulers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "OrientationAnalysis/utilities/OrientationUtilities.hpp"

#include "simplnx/DataStructure/DataArray.hpp"
#include "simplnx/Utilities/Math/MatrixMath.hpp"

#include <EbsdLib/LaueOps/LaueOps.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "simplnx/DataStructure/DataArray.hpp"
#include "simplnx/DataStructure/Geometry/ImageGeom.hpp"
#include "simplnx/DataStructure/StringArray.hpp"
#include "simplnx/Utilities/Math/MatrixMath.hpp"
#include "simplnx/Utilities/StringUtilities.hpp"

#include <EbsdLib/Core/Orientation.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "simplnx/DataStructure/DataArray.hpp"
#include "simplnx/DataStructure/Geometry/ImageGeom.hpp"
#include "simplnx/DataStructure/StringArray.hpp"
#include "simplnx/Utilities/Math/MatrixMath.hpp"
#include "simplnx/Utilities/StringUtilities.hpp"

#include <EbsdLib/Core/Orientation.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#include "OrientationAnalysis/utilities/OrientationUtilities.hpp"

#include "simplnx/Common/Array.hpp"
#include "simplnx/Common/Numbers.hpp"
#include "simplnx/DataStructure/DataArray.hpp"
#include "simplnx/Utilities/Math/MatrixMath.hpp"
#include "simplnx/Utilities/MessageHelper.hpp"
#include "simplnx/Utilities/ParallelDataAlgorithm.hpp"

Expand All @@ -25,7 +25,7 @@ class RotateEulerRefFrameImpl
{

public:
RotateEulerRefFrameImpl(Float32Array& data, std::vector<float>& rotAxis, float angle, const std::atomic_bool& shouldCancel, ProgressMessageHelper& progressMessageHelper)
RotateEulerRefFrameImpl(Float32Array& data, const FloatVec3& rotAxis, float angle, const std::atomic_bool& shouldCancel, ProgressMessageHelper& progressMessageHelper)
: m_CellEulerAngles(data)
, m_AxisAngle(rotAxis)
, m_Angle(angle)
Expand Down Expand Up @@ -77,7 +77,7 @@ class RotateEulerRefFrameImpl

private:
Float32Array& m_CellEulerAngles;
std::vector<float> m_AxisAngle;
FloatVec3 m_AxisAngle;
float m_Angle = 0.0F;
const std::atomic_bool& m_ShouldCancel;
ProgressMessageHelper& m_ProgressMessageHelper;
Expand Down Expand Up @@ -108,8 +108,8 @@ Result<> RotateEulerRefFrame::operator()()

size_t totalElements = eulerAngles.getNumberOfTuples();

std::vector<float> axis = {m_InputValues->rotationAxis[0], m_InputValues->rotationAxis[1], m_InputValues->rotationAxis[2]};
MatrixMath::Normalize3x1(axis.data());
nx::core::FloatVec3 axis = {m_InputValues->rotationAxis[0], m_InputValues->rotationAxis[1], m_InputValues->rotationAxis[2]};
axis = axis.normalize();

MessageHelper messageHelper(m_MessageHandler);
ProgressMessageHelper progressMessageHelper = messageHelper.createProgressMessageHelper();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
#include "WriteGBCDGMTFile.hpp"

// #include "OrientationAnalysis/Math/Matrix3X1.hpp"
// #include "OrientationAnalysis/Math/Matrix3X3.hpp"

#include <EbsdLib/Core/Orientation.hpp>
#include <EbsdLib/LaueOps/LaueOps.h>
#include <EbsdLib/Orientation/OrientationFwd.hpp>

#include "simplnx/Common/Array.hpp"
#include "simplnx/Common/Constants.hpp"
#include "simplnx/DataStructure/DataArray.hpp"
#include "simplnx/DataStructure/DataGroup.hpp"
#include "simplnx/Utilities/FilterUtilities.hpp"
#include "simplnx/Utilities/Math/MatrixMath.hpp"

#include <cmath>
#include <filesystem>
Expand Down Expand Up @@ -137,8 +134,8 @@ Result<> WriteGBCDGMTFile::operator()()

{
const float32 misAngle = m_InputValues->MisorientationRotation[0] * nx::core::Constants::k_PiOver180F;
std::array<float32, 3> normAxis = {m_InputValues->MisorientationRotation[1], m_InputValues->MisorientationRotation[2], m_InputValues->MisorientationRotation[3]};
MatrixMath::Normalize3x1(normAxis.data());
nx::core::FloatVec3 normAxis = {m_InputValues->MisorientationRotation[1], m_InputValues->MisorientationRotation[2], m_InputValues->MisorientationRotation[3]};
normAxis = normAxis.normalize();
// convert axis angle to matrix representation of misorientation
auto out = ebsdlib::AxisAngleDType(normAxis[0], normAxis[1], normAxis[2], misAngle).toOrientationMatrix();
dg = Matrix3X3Type(out.data());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

#include "CalculateTriangleGroupCurvatures.hpp"

#include "simplnx/Utilities/Math/MatrixMath.hpp"
#include "simplnx/Common/Matrix3X3.hpp"
#include "simplnx/Utilities/ParallelAlgorithmUtilities.hpp"

#include "SimplnxCore/Filters/Algorithms/FindNRingNeighbors.hpp"
Expand Down Expand Up @@ -256,40 +256,40 @@ void CalculateTriangleGroupCurvatures::operator()() const
double sub[3] = {patchCentroids->getComponentValue(0, 0), patchCentroids->getComponentValue(0, 1), patchCentroids->getComponentValue(0, 2)};
subtractVector3d(*patchCentroids, sub);

double np[3] = {patchNormals->getComponentValue(0, 0), patchNormals->getComponentValue(0, 1), patchNormals->getComponentValue(0, 2)};
nx::core::Matrix3X1D np = {patchNormals->getComponentValue(0, 0), patchNormals->getComponentValue(0, 1), patchNormals->getComponentValue(0, 2)};

double seedCentroid[3] = {patchCentroids->getComponentValue(0, 0), patchCentroids->getComponentValue(0, 1), patchCentroids->getComponentValue(0, 2)};
double firstCentroid[3] = {patchCentroids->getComponentValue(1, 0), patchCentroids->getComponentValue(1, 1), patchCentroids->getComponentValue(1, 2)};
nx::core::Matrix3X1D seedCentroid = {patchCentroids->getComponentValue(0, 0), patchCentroids->getComponentValue(0, 1), patchCentroids->getComponentValue(0, 2)};
nx::core::Matrix3X1D firstCentroid = {patchCentroids->getComponentValue(1, 0), patchCentroids->getComponentValue(1, 1), patchCentroids->getComponentValue(1, 2)};

double temp[3] = {firstCentroid[0] - seedCentroid[0], firstCentroid[1] - seedCentroid[1], firstCentroid[2] - seedCentroid[2]};
double vp[3] = {0.0, 0.0, 0.0};
nx::core::Matrix3X1D temp = {firstCentroid[0] - seedCentroid[0], firstCentroid[1] - seedCentroid[1], firstCentroid[2] - seedCentroid[2]};
nx::core::Matrix3X1D vp = {0.0, 0.0, 0.0};

// Cross Product of np and temp
MatrixMath::Normalize3x1(np);
MatrixMath::CrossProduct(np, temp, vp);
MatrixMath::Normalize3x1(vp);
np = np.normalize();
vp = np.cross(temp).normalize();

// get the third orthogonal vector
double up[3] = {0.0, 0.0, 0.0};
MatrixMath::CrossProduct(vp, np, up);
Matrix3X1D up = vp.cross(np).normalize();

// this constitutes a rotation matrix to a local coordinate system
double rot[3][3] = {{up[0], up[1], up[2]}, {vp[0], vp[1], vp[2]}, {np[0], np[1], np[2]}};
double out[3] = {0.0, 0.0, 0.0};
nx::core::Matrix3X3D rot = {up[0], up[1], up[2], vp[0], vp[1], vp[2], np[0], np[1], np[2]};
double outPtr[3] = {0.0, 0.0, 0.0};
// Transform all centroids and normals to a new coordinate system
for(size_t m = 0; m < patchCentroids->getNumberOfTuples(); ++m)
{
::memcpy(out, &patchCentroids->data()[m * 3], 3 * sizeof(double));
MatrixMath::Multiply3x3with3x1(rot, &patchCentroids->data()[m * 3], out);
nx::core::Matrix3X1D patchCentroid = {patchCentroids->getComponentValue(m, 0), patchCentroids->getComponentValue(m, 1), patchCentroids->getComponentValue(m, 2)};
auto out = rot * patchCentroid;

if(std::isnan(out[0]) || std::isnan(out[1]) || std::isnan(out[2]))
{
break;
}
::memcpy(&patchCentroids->data()[m * 3], out, 3 * sizeof(double));
// Copy the result back into `patchCentroids`
patchCentroids->setTuple(m, out.data());

::memcpy(out, &patchNormals->data()[m * 3], 3 * sizeof(double));
MatrixMath::Multiply3x3with3x1(rot, &patchNormals->data()[m * 3], out);
::memcpy(&patchNormals->data()[m * 3], out, 3 * sizeof(double));
nx::core::Matrix3X1D patchNormal = {patchNormals->getComponentValue(m, 0), patchNormals->getComponentValue(m, 1), patchNormals->getComponentValue(m, 2)};
out = rot * patchNormal;
patchNormals->setTuple(m, out.data());

// We rotate the normals now, but we don't use them yet. If we start using part 3 of Goldfeather's paper, then we
// will need the normals.
Expand Down
Loading
Loading