43 #include <gtest/gtest.h> 45 #include <ACG/Math/VectorT.hh> 46 #include <ACG/Math/GLMatrixT.hh> 47 #include <ACG/Geometry/Spherical.hh> 53 inline Vec3d rot(
const Vec3d &ref,
const Vec3d &normal,
double angle) {
56 rmat.
rotate(angle * M_1_PI * 180.0, normal, ACG::MULT_FROM_LEFT);
60 class Spherical :
public testing::Test {
64 virtual void SetUp() {
67 virtual void TearDown() {
72 TEST_F(Spherical, sphericalInnerAngleSum_zeroTriangle) {
74 const Vec3d n1(1, 0, 0);
75 EXPECT_NEAR(M_PI, ACG::Geometry::sphericalInnerAngleSum(n1, n1, n1), 1e-6);
82 const Vec3d n1(1, 0, 0);
84 EXPECT_NEAR(M_PI, ACG::Geometry::sphericalInnerAngleSum(
85 rot(n1, axis, .1), n1, n1), 1e-6);
86 EXPECT_NEAR(M_PI, ACG::Geometry::sphericalInnerAngleSum(
87 n1, rot(n1, axis, .1), n1), 1e-6);
88 EXPECT_NEAR(M_PI, ACG::Geometry::sphericalInnerAngleSum(
89 n1, n1, rot(n1, axis, .1)), 1e-6);
90 EXPECT_NEAR(M_PI, ACG::Geometry::sphericalInnerAngleSum(
91 rot(n1, axis, .1), rot(n1, axis, -.05), rot(n1, axis, .07)), 1e-6);
97 EXPECT_NEAR(M_PI, ACG::Geometry::sphericalInnerAngleSum(
98 rot(n1, axis, .1), rot(n1, axis, -.05), rot(n1, axis, .07)), 1e-6);
102 TEST_F(Spherical, sphericalPolyhedralGaussCurv_pointPolyhedral) {
103 std::vector<Vec3d> normals;
104 normals.push_back(
Vec3d(1, 0, 0));
105 normals.push_back(
Vec3d(1, 0, 0));
106 normals.push_back(
Vec3d(1, 0, 0));
107 normals.push_back(
Vec3d(1, 0, 0));
109 EXPECT_NEAR(0, ACG::Geometry::sphericalPolyhedralGaussCurv<Vec3d>(normals.begin(), normals.end()), 1e-6);
113 for (
int i = 0; i < 7; ++i) normals.push_back(v);
115 EXPECT_NEAR(0, ACG::Geometry::sphericalPolyhedralGaussCurv<Vec3d>(normals.begin(), normals.end()), 1e-6);
118 TEST_F(Spherical, sphericalPolyhedralGaussCurv_linePolyhedral) {
123 const Vec3d axis = (n1 %
Vec3d(3, 1, 2)).normalized();
125 std::vector<Vec3d> normals;
126 normals.push_back(rot(n1, axis, .1));
127 normals.push_back(rot(n1, axis, .2));
128 normals.push_back(rot(n1, axis, .05));
129 normals.push_back(rot(n1, axis, .09));
130 normals.push_back(rot(n1, axis, -.2));
131 normals.push_back(rot(n1, axis, .01));
132 normals.push_back(rot(n1, axis, -.1));
133 normals.push_back(rot(n1, axis, -.2));
135 EXPECT_NEAR(0, ACG::Geometry::sphericalPolyhedralGaussCurv<Vec3d>(normals.begin(), normals.end()), 1e-6);
138 TEST_F(Spherical, sphericalPolyhedralGaussCurv_cubeCorner) {
140 std::vector<Vec3d> normals;
141 normals.push_back(
Vec3d(1, 0, 0));
142 normals.push_back(
Vec3d(0, 1, 0));
143 normals.push_back(
Vec3d(0, 0, 1));
145 EXPECT_NEAR(M_PI_2, ACG::Geometry::sphericalPolyhedralGaussCurv<Vec3d>(normals.begin(), normals.end()), 1e-6);
150 TEST_F(Spherical, sphericalPolyhedralGaussCurv_houseCorner) {
151 std::vector<Vec3d> normals;
152 normals.push_back(
Vec3d(0, 0, 1));
153 normals.push_back(
Vec3d(0, 1, 0));
154 normals.push_back(
Vec3d(0, 1, 0));
155 normals.push_back(
Vec3d(0, 1, 0));
156 normals.push_back(
Vec3d(1, 0, 0));
158 EXPECT_NEAR(-M_PI_2, ACG::Geometry::sphericalPolyhedralGaussCurv<Vec3d>(normals.begin(), normals.end()), 1e-6);
auto normalized() const -> decltype(*this/std::declval< VectorT< S, DIM >>().norm())
VectorT< double, 3 > Vec3d
void identity()
setup an identity matrix
void rotate(Scalar angle, Scalar x, Scalar y, Scalar z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
VectorT< T, 3 > transform_vector(const VectorT< T, 3 > &_v) const
transform vector (x',y',z',0) = A * (x,y,z,0)