{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "nbsphinx": "hidden" }, "outputs": [], "source": [ "import open3d as o3d\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import copy\n", "import os\n", "import sys\n", "\n", "# only needed for tutorial, monkey patches visualization\n", "sys.path.append('..')\n", "import open3d_tutorial as o3dtut\n", "# change to True if you want to interact with the visualization windows\n", "o3dtut.interactive = not \"CI\" in os.environ" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Transformation\n", "The geometry types of Open3D have a number of transformation methods. In this tutorial we show how to use `translate`, `rotate`, `scale`, and `transform`." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Translate\n", "The first transformation method we want to look at is `translate`. The translate method takes a single 3D vector $t$ as input and translates all points/vertices of the geometry by this vector, $v_t = v + t$. The code below shows how the mesh is once translated in the x- and once in the y-direction." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "mesh = o3d.geometry.TriangleMesh.create_coordinate_frame()\n", "mesh_tx = copy.deepcopy(mesh).translate((1.3,0,0))\n", "mesh_ty = copy.deepcopy(mesh).translate((0,1.3,0))\n", "print(f'Center of mesh: {mesh.get_center()}')\n", "print(f'Center of mesh tx: {mesh_tx.get_center()}')\n", "print(f'Center of mesh ty: {mesh_ty.get_center()}')\n", "o3d.visualization.draw_geometries([mesh, mesh_tx, mesh_ty])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "