Python example: lines-3d-geometry-example.py
This example illustrates some geometry functions:
1#!/usr/bin/env python3
2
3# ---------------------------------------------------------------------
4# Install python3-pymrpt, ros-$ROS_DISTRO-python-mrpt,
5# ros-$ROS_DISTRO-mrpt2, or test with a local build with:
6# export PYTHONPATH=$HOME/code/mrpt/build-Release/:$PYTHONPATH
7# ---------------------------------------------------------------------
8
9from mrpt.pymrpt import mrpt
10
11# Aliases:
12TPoint3D = mrpt.math.TPoint3D_double_t
13TLine3D = mrpt.math.TLine3D
14
15l1: TLine3D = TLine3D.FromTwoPoints(TPoint3D(0, 0, 0), TPoint3D(1, 0, 0))
16l2: TLine3D = TLine3D.FromTwoPoints(TPoint3D(1, 1, 1), TPoint3D(2, 2, 0))
17
18print('l1 : ' + str(l1))
19print('l2 : ' + str(l2))
20print('dist(l1,l2) : ' + str(mrpt.math.distance(l1, l2)))
21print('l1.director : ' + l1.getDirectorVector().asString())
Output:
1l1 : P=[ 0.00000, 0.00000, 0.00000] u=[ 1.00000, 0.00000, 0.00000]
2l2 : P=[ 1.00000, 1.00000, 1.00000] u=[ 1.00000, 1.00000, -1.00000]
3dist(l1,l2) : 1.414213562373095