Previous Tutorial: C++ Get Started
Overview
This tutorial describes how to get started using Ignition Math with Python.
NOTE: If you have compiled Ignition Math from source, you should export your PYTHONPATH
.
We will run through an example that determines the distance between two points in 3D space. Start by creating a bare-bones main file using the editor of your choice.
The easiest way to include Ignition Math is through import ignition.math
.
At this point your main file should look like
Now let's create two 3D points with arbitrary values. We will use the ignition.math.Vector3
class to represent these points. Ignition Math provides some Vector3
types which are: Vector3d
(Vector3 using doubles), Vector3f
(Vector3 using floats) and Vector3i
(Vector3 using integers). The result of this addition will be a main file similar to the following.
Finally, we can compute the distance between point1
and point2
using the ignition.math.Vector3.distance()
function and output the distance value.