ProSHADE  0.7.6.6 (JUL 2022)
Protein Shape Detection
pyProSHADE_maths.cpp
Go to the documentation of this file.
1 
22 //==================================================== Include PyBind11 header
23 #include <pybind11/pybind11.h>
24 #include <pybind11/stl.h>
25 #include <pybind11/numpy.h>
26 
27 //==================================================== Add the ProSHADE_settings and ProSHADE_run classes to the PyBind11 module
28 void add_mathsNamespace ( pybind11::module& pyProSHADE )
29 {
30  pyProSHADE.def ( "getAngleAxisFromEulerAngles",
31  [] ( proshade_double eulerAlpha, proshade_double eulerBeta, proshade_double eulerGamma ) -> pybind11::array_t < proshade_double >
32  {
33  //== Allocate output memory
34  proshade_double* retVals = new proshade_double[4];
35  ProSHADE_internal_misc::checkMemoryAllocation ( retVals, __FILE__, __LINE__, __func__ );
36 
37  //== Allocate workspace memory
38  proshade_double* rMat = new proshade_double[9];
39  ProSHADE_internal_misc::checkMemoryAllocation ( rMat, __FILE__, __LINE__, __func__ );
40  proshade_double aX, aY, aZ, aA;
41 
42  //== Compute the conversion
43  ProSHADE_internal_maths::getRotationMatrixFromEulerZYZAngles ( eulerAlpha, eulerBeta, eulerGamma, rMat );
45 
46  //== Release workspace memory
47  delete[] rMat;
48 
49  //== Save output
50  retVals[0] = aX;
51  retVals[1] = aY;
52  retVals[2] = aZ;
53  retVals[3] = aA;
54 
55  //== Create capsules to make sure memory is released properly from the allocating language (C++ in this case)
56  pybind11::capsule pyCapsuleAAFromEA ( retVals, []( void *f ) { proshade_double* foo = reinterpret_cast< proshade_double* > ( f ); delete foo; } );
57 
58  //== Copy the value
59  pybind11::array_t < proshade_double > retArr = pybind11::array_t < proshade_double > ( { 4 }, // Shape
60  { sizeof(proshade_double) }, // C-stype strides
61  retVals, // Data
62  pyCapsuleAAFromEA ); // Capsule
63 
64  //== Done
65  return ( retArr );
66  }, "This function converts the ZYZ Euler angles to angle-axis representation, returning numpy.ndarray with the following four numbers: [0] = x-axis; [1] = y-axis; [2] = z-axis; [3] = angle." );
67 }
ProSHADE_internal_maths::getRotationMatrixFromEulerZYZAngles
void getRotationMatrixFromEulerZYZAngles(proshade_double eulerAlpha, proshade_double eulerBeta, proshade_double eulerGamma, proshade_double *matrix)
Function to find the rotation matrix from Euler angles (ZYZ convention).
Definition: ProSHADE_maths.cpp:1019
ProSHADE_internal_maths::getAxisAngleFromRotationMatrix
void getAxisAngleFromRotationMatrix(proshade_double *rotMat, proshade_double *x, proshade_double *y, proshade_double *z, proshade_double *ang, proshade_signed verbose=1)
This function converts rotation matrix to the axis-angle representation.
Definition: ProSHADE_maths.cpp:1083
ProSHADE_internal_misc::checkMemoryAllocation
void checkMemoryAllocation(chVar checkVar, std::string fileP, unsigned int lineP, std::string funcP, std::string infoP="This error may occurs when ProSHADE requests memory to be\n : allocated to it and this operation fails. This could\n : happen when not enough memory is available, either due to\n : other processes using a lot of memory, or when the machine\n : does not have sufficient memory available. Re-run to see\n : if this problem persists.")
Checks if memory was allocated properly.
Definition: ProSHADE_misc.hpp:73