Skip to content

Commit

Permalink
Merge branch 'develop' into feature/kweiss/fix-gh-action-manual-windows
Browse files Browse the repository at this point in the history
  • Loading branch information
kennyweiss committed Sep 26, 2024
2 parents 981cdf9 + bb0dbfb commit b779c7c
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 3 deletions.
3 changes: 3 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ The Axom project release numbers follow [Semantic Versioning](http://semver.org/
config variables.
- Removes caching of `{PACKAGE}_FOUND` variables in `SetupAxomThirdParty.cmake`

### Fixed
- `numerics::eigen_solve()` has been corrected to avoid an early return with error state.

## [Version 0.9.0] - Release date 2024-03-19

### Added
Expand Down
9 changes: 6 additions & 3 deletions src/axom/core/numerics/eigen_solve.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace numerics
* \param [in] A a square input matrix
* \param [in] k number of eigenvalue-eigenvectors to find
* \param [out] u pointer to k eigenvectors in order by magnitude of eigenvalue
* \param [out] lambdas pointer to k eigenvales in order by size
* \param [out] lambdas pointer to k eigenvalues in order by size
* \param [in] numIterations optional number of iterations for the power method
* \note if k <= 0, the solve is declared successful
* \return rc return value, nonzero if the solve is successful.
Expand Down Expand Up @@ -119,9 +119,12 @@ int eigen_solve(Matrix<T>& A, int k, T* u, T* lambdas, int numIterations)

bool res = normalize<T>(vec, N);

if(!res) // something went wrong
// something went wrong, likely because `vec` is (numerically)
// in the span of the previous eigenvectors. Try again!
if(!res)
{
return 0;
i--;
continue;
}

// 3: run depth iterations of power method; note that a loop invariant
Expand Down
75 changes: 75 additions & 0 deletions src/axom/primal/tests/primal_orientedboundingbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,81 @@ TEST(primal_OBBox, obb_ctor_from_data)
EXPECT_TRUE(obbox1.getExtents() == e);
}

//------------------------------------------------------------------------------
TEST(primal_OBBox, obb_ctor_from_point_array)
{
constexpr int DIM = 3;
using CoordType = double;
using QPoint = primal::Point<CoordType, DIM>;
using QOBBox = primal::OrientedBoundingBox<CoordType, DIM>;

QPoint pt1; // origin
QPoint pt2({1.0, 0.0, 0.0});
QPoint pt3({0.0, 1.0, 0.0});
QPoint pt4({0.0, 0.0, 1.0});
QPoint pt5({1.0, 1.0, 0.0});
QPoint pt6({1.0, 0.0, 1.0});
QPoint pt7({0.0, 1.0, 1.0});
QPoint pt8({1.0, 1.0, 1.0});

/* -1D OBB */
QPoint* pts_00 = nullptr;
QOBBox obbox00(pts_00, 0);

EXPECT_FALSE(obbox00.isValid());

/* 0D OBB */
QPoint pts_0d[] = {pt1};
QOBBox obbox0(pts_0d, 1);

EXPECT_TRUE(obbox0.isValid());
EXPECT_TRUE(obbox0.contains(pt1));

EXPECT_NEAR(obbox0.getCentroid()[0], 0.0, 1e-6);
EXPECT_NEAR(obbox0.getCentroid()[1], 0.0, 1e-6);
EXPECT_NEAR(obbox0.getCentroid()[2], 0.0, 1e-6);

/* 1D OBB */
QPoint pts_1d[] = {pt1, pt2};
QOBBox obbox1(pts_1d, 2);

EXPECT_TRUE(obbox1.isValid());
EXPECT_TRUE(obbox1.contains(pt1));
EXPECT_TRUE(obbox1.contains(pt2));

EXPECT_NEAR(obbox1.getCentroid()[0], 0.5, 1e-6);
EXPECT_NEAR(obbox1.getCentroid()[1], 0.0, 1e-6);
EXPECT_NEAR(obbox1.getCentroid()[2], 0.0, 1e-6);

/* 2D OBB */
QPoint pts_2d[] = {pt1, pt2, pt3, pt5};
QOBBox obbox2(pts_2d, 4);

EXPECT_TRUE(obbox2.isValid());
EXPECT_TRUE(obbox2.contains(pt1));
EXPECT_TRUE(obbox2.contains(pt2));
EXPECT_TRUE(obbox2.contains(pt3));
EXPECT_TRUE(obbox2.contains(pt5));

EXPECT_NEAR(obbox2.getCentroid()[0], 0.5, 1e-6);
EXPECT_NEAR(obbox2.getCentroid()[1], 0.5, 1e-6);
EXPECT_NEAR(obbox2.getCentroid()[2], 0.0, 1e-6);

/* 3D OBB */
QPoint pts_3d[] = {pt1, pt2, pt3, pt4, pt5, pt6, pt7, pt8};
QOBBox obbox3(pts_3d, 8);

// check containments
EXPECT_TRUE(obbox3.isValid());
for(int i = 0; i < 8; i++)
{
EXPECT_TRUE(obbox3.contains(pts_3d[i]));
}

// check settings
EXPECT_TRUE(obbox3.getCentroid() == QPoint(0.5));
}

//------------------------------------------------------------------------------
TEST(primal_OBBox, obb_test_clear)
{
Expand Down

0 comments on commit b779c7c

Please sign in to comment.