49 #include <gtest/gtest.h>
51 #include <ACG/Math/VectorT.hh>
52 #include <ACG/Math/GLMatrixT.hh>
53 #include <ACG/Geometry/Spherical.hh>
59 inline Vec3d rot(
const Vec3d &ref,
const Vec3d &normal,
double angle) {
62 rmat.
rotate(angle * M_1_PI * 180.0, normal, ACG::MULT_FROM_LEFT);
66 class Spherical :
public testing::Test {
70 virtual void SetUp() {
73 virtual void TearDown() {
78 TEST_F(Spherical, sphericalInnerAngleSum_zeroTriangle) {
80 const Vec3d n1(1, 0, 0);
81 EXPECT_NEAR(M_PI, ACG::Geometry::sphericalInnerAngleSum(n1, n1, n1), 1e-6);
88 const Vec3d n1(1, 0, 0);
89 const Vec3d axis = (n1 %
Vec3d(3, 1, 2).normalized()).normalized();
90 EXPECT_NEAR(M_PI, ACG::Geometry::sphericalInnerAngleSum(
91 rot(n1, axis, .1), n1, n1), 1e-6);
92 EXPECT_NEAR(M_PI, ACG::Geometry::sphericalInnerAngleSum(
93 n1, rot(n1, axis, .1), n1), 1e-6);
94 EXPECT_NEAR(M_PI, ACG::Geometry::sphericalInnerAngleSum(
95 n1, n1, rot(n1, axis, .1)), 1e-6);
96 EXPECT_NEAR(M_PI, ACG::Geometry::sphericalInnerAngleSum(
97 rot(n1, axis, .1), rot(n1, axis, -.05), rot(n1, axis, .07)), 1e-6);
102 const Vec3d axis = (n1 %
Vec3d(3, 1, 2).normalized()).normalized();
103 EXPECT_NEAR(M_PI, ACG::Geometry::sphericalInnerAngleSum(
104 rot(n1, axis, .1), rot(n1, axis, -.05), rot(n1, axis, .07)), 1e-6);
108 TEST_F(Spherical, sphericalPolyhedralGaussCurv_pointPolyhedral) {
109 std::vector<Vec3d> normals;
110 normals.push_back(
Vec3d(1, 0, 0));
111 normals.push_back(
Vec3d(1, 0, 0));
112 normals.push_back(
Vec3d(1, 0, 0));
113 normals.push_back(
Vec3d(1, 0, 0));
115 EXPECT_NEAR(0, ACG::Geometry::sphericalPolyhedralGaussCurv<Vec3d>(normals.begin(), normals.end()), 1e-6);
119 for (
int i = 0; i < 7; ++i) normals.push_back(v);
121 EXPECT_NEAR(0, ACG::Geometry::sphericalPolyhedralGaussCurv<Vec3d>(normals.begin(), normals.end()), 1e-6);
124 TEST_F(Spherical, sphericalPolyhedralGaussCurv_linePolyhedral) {
129 const Vec3d axis = (n1 %
Vec3d(3, 1, 2)).normalized();
131 std::vector<Vec3d> normals;
132 normals.push_back(rot(n1, axis, .1));
133 normals.push_back(rot(n1, axis, .2));
134 normals.push_back(rot(n1, axis, .05));
135 normals.push_back(rot(n1, axis, .09));
136 normals.push_back(rot(n1, axis, -.2));
137 normals.push_back(rot(n1, axis, .01));
138 normals.push_back(rot(n1, axis, -.1));
139 normals.push_back(rot(n1, axis, -.2));
141 EXPECT_NEAR(0, ACG::Geometry::sphericalPolyhedralGaussCurv<Vec3d>(normals.begin(), normals.end()), 1e-6);
144 TEST_F(Spherical, sphericalPolyhedralGaussCurv_cubeCorner) {
146 std::vector<Vec3d> normals;
147 normals.push_back(
Vec3d(1, 0, 0));
148 normals.push_back(
Vec3d(0, 1, 0));
149 normals.push_back(
Vec3d(0, 0, 1));
151 EXPECT_NEAR(M_PI_2, ACG::Geometry::sphericalPolyhedralGaussCurv<Vec3d>(normals.begin(), normals.end()), 1e-6);
156 TEST_F(Spherical, sphericalPolyhedralGaussCurv_houseCorner) {
157 std::vector<Vec3d> normals;
158 normals.push_back(
Vec3d(0, 0, 1));
159 normals.push_back(
Vec3d(0, 1, 0));
160 normals.push_back(
Vec3d(0, 1, 0));
161 normals.push_back(
Vec3d(0, 1, 0));
162 normals.push_back(
Vec3d(1, 0, 0));
164 EXPECT_NEAR(-M_PI_2, ACG::Geometry::sphericalPolyhedralGaussCurv<Vec3d>(normals.begin(), normals.end()), 1e-6);
VectorT< double, 3 > Vec3d
VectorT< T, 3 > transform_vector(const VectorT< T, 3 > &_v) const
transform vector (x',y',z',0) = A * (x,y,z,0)
void rotate(Scalar angle, Scalar x, Scalar y, Scalar z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
void identity()
setup an identity matrix