Skip to content

Commit 29158b3

Browse files
committed
Merge branch 'main' into ogc
2 parents c400d7e + 296fe4a commit 29158b3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+759
-61
lines changed

python/src/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ add_subdirectory(ccd)
1818
add_subdirectory(collisions)
1919
add_subdirectory(distance)
2020
add_subdirectory(friction)
21+
add_subdirectory(geometry)
2122
add_subdirectory(implicits)
23+
add_subdirectory(math)
2224
add_subdirectory(ogc)
2325
add_subdirectory(potentials)
2426
add_subdirectory(tangent)

python/src/bindings.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,18 @@ PYBIND11_MODULE(ipctk, m)
9090

9191
define_smooth_potential(m);
9292

93+
// geometry
94+
define_angle(m);
95+
define_area(m);
96+
define_intersection(m);
97+
define_normal(m);
98+
9399
// implicits
94100
define_plane_implicit(m);
95101

102+
// math
103+
define_interval(m);
104+
96105
// ogc
97106
py::module_ ogc =
98107
m.def_submodule("ogc", "Offset Geometric Contact (OGC) helpers");
@@ -108,9 +117,6 @@ PYBIND11_MODULE(ipctk, m)
108117
define_tangential_adhesion_potential(m);
109118

110119
// utils
111-
define_area_gradient(m);
112-
define_interval(m);
113-
define_intersection(m);
114120
define_logger(m);
115121
define_thread_limiter(m);
116122
define_vertex_to_min_edge(m);

python/src/bindings.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
#include <collisions/bindings.hpp>
99
#include <distance/bindings.hpp>
1010
#include <friction/bindings.hpp>
11+
#include <geometry/bindings.hpp>
1112
#include <implicits/bindings.hpp>
13+
#include <math/bindings.hpp>
1214
#include <ogc/bindings.hpp>
1315
#include <potentials/bindings.hpp>
1416
#include <tangent/bindings.hpp>

python/src/geometry/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
set(SOURCES
2+
area.cpp
3+
angle.cpp
4+
normal.cpp
5+
intersection.cpp
6+
)
7+
8+
target_sources(ipctk PRIVATE ${SOURCES})

python/src/geometry/angle.cpp

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#include <common.hpp>
2+
3+
#include <ipc/geometry/angle.hpp>
4+
5+
using namespace ipc;
6+
7+
void define_angle(py::module_& m)
8+
{
9+
m.def(
10+
"dihedral_angle", &dihedral_angle,
11+
R"ipc_Qu8mg5v7(
12+
Compute the bending angle between two triangles sharing an edge.
13+
x0---x2
14+
| \ |
15+
x1---x3
16+
17+
Parameters
18+
----------
19+
x0 : Eigen::Vector3d
20+
The first vertex of the edge.
21+
x1 : Eigen::Vector3d
22+
The second vertex of the edge.
23+
x2 : Eigen::Vector3d
24+
The opposite vertex of the first triangle.
25+
x3 : Eigen::Vector3d
26+
The opposite vertex of the second triangle.
27+
28+
Returns
29+
-------
30+
double
31+
The bending angle between the two triangles.
32+
)ipc_Qu8mg5v7",
33+
py::arg("x0"), py::arg("x1"), py::arg("x2"), py::arg("x3"));
34+
35+
m.def(
36+
"dihedral_angle_gradient", &dihedral_angle_gradient,
37+
R"ipc_Qu8mg5v7(
38+
Compute the Jacobian of the bending angle between two triangles sharing an edge.
39+
x0---x2
40+
| \ |
41+
x1---x3
42+
43+
Parameters
44+
----------
45+
x0 : Eigen::Vector3d
46+
The first vertex of the edge.
47+
x1 : Eigen::Vector3d
48+
The second vertex of the edge.
49+
x2 : Eigen::Vector3d
50+
The opposite vertex of the first triangle.
51+
x3 : Eigen::Vector3d
52+
The opposite vertex of the second triangle.
53+
54+
Returns
55+
-------
56+
Eigen::Vector<double, 12>
57+
The Jacobian matrix of the bending angle with respect to the input vertices.
58+
)ipc_Qu8mg5v7",
59+
py::arg("x0"), py::arg("x1"), py::arg("x2"), py::arg("x3"));
60+
}

python/src/utils/area_gradient.cpp renamed to python/src/geometry/area.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#include <common.hpp>
22

3-
#include <ipc/utils/area_gradient.hpp>
3+
#include <ipc/geometry/area.hpp>
44
#include <ipc/utils/eigen_ext.hpp>
55

66
using namespace ipc;
77

8-
void define_area_gradient(py::module_& m)
8+
void define_area(py::module_& m)
99
{
1010
m.def(
1111
"edge_length_gradient", &edge_length_gradient,

python/src/geometry/bindings.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#pragma once
2+
3+
#include <pybind11/pybind11.h>
4+
5+
void define_angle(py::module_& m);
6+
void define_area(py::module_& m);
7+
void define_normal(py::module_& m);
8+
void define_intersection(py::module_& m);

python/src/utils/intersection.cpp renamed to python/src/geometry/intersection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <common.hpp>
22

3-
#include <ipc/utils/intersection.hpp>
3+
#include <ipc/geometry/intersection.hpp>
44

55
#include <igl/predicates/segment_segment_intersect.h>
66

0 commit comments

Comments
 (0)