Commit 4472e953 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[python] mofify wrappers for common

the rotate() function has been moved to the geometry module, and the
wrappers for toDegrees() or toRadians() have been removed as Python
offers such functions
parent defc80dd
Pipeline #2848 passed with stages
in 9 minutes and 25 seconds
......@@ -141,6 +141,7 @@ ctype toRadians(const ctype degrees)
* \param angle The rotation angle
* \note The rotation matrix is taken from:
* https://en.wikipedia.org/wiki/Rotation_matrix#Rotation_matrix_from_axis_and_angle
* \todo TODO: This should probably be moved to geometry
*/
template<class ctype>
void rotate(Vector<ctype, 3>& v,
......@@ -176,6 +177,7 @@ void rotate(Vector<ctype, 3>& v,
* vector several times, as the rotation matrix is only constructed once!
* \note The rotation matrix is taken from:
* https://en.wikipedia.org/wiki/Rotation_matrix#Rotation_matrix_from_axis_and_angle
* \todo TODO: This should probably be moved to geometry
*/
template<class ctype>
void rotate(std::vector<Vector<ctype, 3>>& vectors,
......
install(FILES
id.hh
math.hh
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/frackit/python/common)
......@@ -26,6 +26,7 @@ point.hh
polygon.hh
quadrilateral.hh
registerdimensionproperties.hh
rotate.hh
segment.hh
sphere.hh
triangle.hh
......
......@@ -16,11 +16,10 @@
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
#ifndef FRACKIT_PYTHON_COMMON_MATH_HH
#define FRACKIT_PYTHON_COMMON_MATH_HH
#ifndef FRACKIT_PYTHON_GEOMETRY_ROTATE_HH
#define FRACKIT_PYTHON_GEOMETRY_ROTATE_HH
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <frackit/geometry/vector.hh>
#include <frackit/geometry/direction.hh>
......@@ -31,11 +30,8 @@ namespace Frackit::Python {
namespace py = pybind11;
template<class ctype>
void registerMath(py::module& module)
void registerRotate(py::module& module)
{
module.def("toDegrees", &Frackit::toDegrees<ctype>, "Converts radians into degrees");
module.def("toRadians", &Frackit::toRadians<ctype>, "Converts degrees into radians");
// Register rotation overload for single vector
using namespace py::literals;
using Vector_3 = Vector<ctype, 3>;
......
......@@ -18,10 +18,8 @@
*****************************************************************************/
#include <pybind11/pybind11.h>
#include <frackit/python/common/id.hh>
#include <frackit/python/common/math.hh>
PYBIND11_MODULE(_common, module)
{
Frackit::Python::registerId(module);
Frackit::Python::registerMath<double>(module);
}
......@@ -47,6 +47,7 @@
#include <frackit/python/geometry/magnitude.hh>
#include <frackit/python/geometry/intersect.hh>
#include <frackit/python/geometry/getboundingbox.hh>
#include <frackit/python/geometry/rotate.hh>
PYBIND11_MODULE(_geometry, module)
{
......@@ -96,4 +97,7 @@ PYBIND11_MODULE(_geometry, module)
// bounding box computation
Frackit::Python::registerGetBoundingBox<double>(module);
// rotation algorithms
Frackit::Python::registerRotate<double>(module);
}
......@@ -193,7 +193,7 @@ class DiskSampler:
e2 = Direction_3(axes[1])
e3 = Direction_3(Vector_3(0.0, 0.0, 1.0))
from frackit.common import rotate
from frackit.geometry import rotate
rotate(axes[1], e1, alpha) # rotate minor axis around x
rotate(axes[0], e2, beta) # rotate both axes around y
rotate(axes[1], e2, beta) # rotate both axes around y
......@@ -338,7 +338,7 @@ class PolygonSampler:
edgeVectors.sort(key=lambda v: getAngle(v))
# rotate by strike and dip angle
from frackit.common import rotate
from frackit.geometry import rotate
from frackit.geometry import Direction
dipAngle = self.dipAngleSampler()
strikeAngle = self.strikeAngleSampler()
......@@ -435,7 +435,7 @@ class QuadrilateralSampler:
axes = [Vector_3(1.0, 0.0, 0.0), Vector_3(0.0, 1.0, 0.0)]
from frackit.geometry import Direction_3
from frackit.common import rotate
from frackit.geometry import rotate
rotate(axes[0], Direction_3(Vector_3(0.0, 0.0, 1.0)), strike);
rotate(axes[1], Direction_3(Vector_3(0.0, 0.0, 1.0)), strike);
rotate(axes[0], Direction_3(axes[1]), dip);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment