15#include "fmt/format.h"
28 const double tol = 1.e-10;
32 std::pair<util::Point, util::Point> box = {
util::Point(),
38 for (
size_t i=0; i<2; i++)
39 for (
size_t j=0; j<2; j++)
40 for (
size_t k=0; k<2; k++) {
42 auto p =
util::Point(
double(i),
double(j),
double(k));
44 for (
auto q : corner_pts) {
49 errExit(fmt::format(
"Error: Can not find corner point {}\n", p.printStr()));
53 errExit(
"Error: getCenter()\n");
59 errExit(
"Error: triangleArea()\n");
64 std::vector<double> x = {1., 0., 0.};
65 std::vector<double> y_check = {1./std::sqrt(2.), -1./std::sqrt(2.), 0.};
68 errExit(
"Error: rotateCW2D()\n");
71 errExit(
"Error: rotateCW2D()\n");
73 y_check = {1./std::sqrt(2.), 1./std::sqrt(2.), 0.};
76 errExit(
"Error: rotateACW2D()\n");
85 if (y_check.dist(y) > tol)
86 errExit(fmt::format(
"Error: rotate(). y_check = {}, y = {}\n", y_check.printStr(), y.printStr()));
91 if (y_check.dist(y) > tol)
92 errExit(fmt::format(
"Error: rotate(). y_check = {}, y = {}\n", y_check.printStr(), y.printStr()));
99 if (std::abs(M_PI*0.25 -
util::angle(x1, x2)) > tol)
103 if (std::abs(M_PI*0.5 -
util::angle(x1, x2)) > tol)
void errExit(std::string msg)
void testUtilMethods()
Test methods
T l2Dist(const std::vector< T > &x1, const std::vector< T > &x2)
Computes l2 distance between two vectors.
std::vector< std::pair< util::Point, util::Point > > getEdges(size_t dim, const std::pair< util::Point, util::Point > &box)
Returns all corner points in the box.
double angle(util::Point a, util::Point b)
Computes angle between two vectors.
std::vector< util::Point > getCornerPoints(size_t dim, const std::pair< util::Point, util::Point > &box)
Returns all corner points in the box.
util::Point getCenter(size_t dim, const std::pair< util::Point, util::Point > &box)
Returns center point.
std::vector< double > rotateACW2D(const std::vector< double > &x, const double &theta)
Rotates a vector in xy-plane in anti-clockwise direction.
std::vector< double > rotateCW2D(const std::vector< double > &x, const double &theta)
Rotates a vector in xy-plane in clockwise direction.
double triangleArea(const util::Point &x1, const util::Point &x2, const util::Point &x3)
Compute area of triangle.
util::Point rotate(const util::Point &p, const double &theta, const util::Point &axis)
Returns the vector after rotating by desired angle.
A structure to represent 3d vectors.