Skip to content

Commit

Permalink
[feature] Improve Python bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-bremond committed Sep 7, 2018
1 parent 3936e0b commit 48856ab
Show file tree
Hide file tree
Showing 11 changed files with 331 additions and 224 deletions.
16 changes: 2 additions & 14 deletions share/python/notebooks/Tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -246,21 +246,9 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'Point' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-1-8bd6738a8164>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mPoint\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mOrigin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m;\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mNameError\u001b[0m: name 'Point' is not defined"
]
}
],
"outputs": [],
"source": [
"Point.Origin() ;"
]
Expand Down
179 changes: 179 additions & 0 deletions share/python/notebooks/Untitled.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import numpy"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"import Library.Core as Core\n",
"import Library.Mathematics as Mathematics"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"D3 = Mathematics.Geometry.D3"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"Point = D3.Objects.Point\n",
"Cuboid = D3.Objects.Cuboid"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"Transformation = D3.Transformation"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"center = Point(0.0, 0.0, 0.0)\n",
"axes = [numpy.array((1.0, 0.0, 0.0)), numpy.array((0.0, 1.0, 0.0)), numpy.array((0.0, 0.0, 1.0))]\n",
"extent = [1.0, 2.0, 3.0]\n",
"\n",
"cuboid = Cuboid(center, axes, extent) ;"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"-- Cuboid ------------------------------------------------------------------------------------------\n",
" Center: [0.0, 0.0, 0.0] \n",
" First axis: [1.0, 0.0, 0.0] \n",
" Second axis: [0.0, 1.0, 0.0] \n",
" Third axis: [0.0, 0.0, 1.0] \n",
" First extent: 1.0 \n",
" Second extent: 2.0 \n",
" Third extent: 3.0 \n",
"----------------------------------------------------------------------------------------------------"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cuboid"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cuboid.intersectsCuboid(cuboid)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"Transformation.Translation(numpy.array((1.0, 2.0, 3.0)))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"transformation = Transformation.Translation(numpy.array((1.0, 2.0, 3.0)))"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'cuboid' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-1-ae09d7daa57f>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mcuboid\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapplyTransformation\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtransformation\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mNameError\u001b[0m: name 'cuboid' is not defined"
]
}
],
"source": [
"cuboid.applyTransformation(transformation)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS (LibraryMathematicsPy_Geometry_3D_Transformations_Rotations_Quaternion_toString_overloads, library::math::geom::d3::trf::rot::Quaternion::toString, 0, 2)

inline void LibraryMathematicsPy_Geometry_3D_Transformations_Rotations_Quaternion ( )
{

Expand Down Expand Up @@ -65,8 +63,8 @@ inline void LibraryMathematicsPy_Geometry_3D_Transformations
.def("dotMultiply", &Quaternion::dotMultiply)
.def("rotateVector", &Quaternion::rotateVector)
.def("toVector", &Quaternion::toVector)
.def("toString", +[] (const Quaternion& aQuaternion) -> String { return aQuaternion.toString() ; })
.def("toString", +[] (const Quaternion& aQuaternion, const Quaternion::Format aFormat) -> String { return aQuaternion.toString(aFormat) ; })
// .def("toString", &Quaternion::toString(), LibraryMathematicsPy_Geometry_3D_Transformations_Rotations_Quaternion_toString_overloads())
.def("normalize", +[] (Quaternion& aQuaternion) -> void { aQuaternion.normalize() ; })
.def("conjugate", +[] (Quaternion& aQuaternion) -> void { aQuaternion.conjugate() ; })
.def("inverse", +[] (Quaternion& aQuaternion) -> void { aQuaternion.inverse() ; })
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 48856ab

Please sign in to comment.