{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Vertex Sampling\n", "Vertex sampling is designed for polygon simplification.\n", "There is a choice of two implementation algorithms: **Douglas-Peucker** and **Visvalingam-Whyatt**." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:27:38.865456Z", "iopub.status.busy": "2024-04-17T07:27:38.865332Z", "iopub.status.idle": "2024-04-17T07:27:39.190358Z", "shell.execute_reply": "2024-04-17T07:27:39.189998Z" } }, "outputs": [], "source": [ "import numpy as np\n", "\n", "from lets_plot import *" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:27:39.191938Z", "iopub.status.busy": "2024-04-17T07:27:39.191757Z", "iopub.status.idle": "2024-04-17T07:27:39.193733Z", "shell.execute_reply": "2024-04-17T07:27:39.193562Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:27:39.207770Z", "iopub.status.busy": "2024-04-17T07:27:39.207594Z", "iopub.status.idle": "2024-04-17T07:27:39.209940Z", "shell.execute_reply": "2024-04-17T07:27:39.209760Z" } }, "outputs": [], "source": [ "def f(x, y, n):\n", " z = np.sin(x * 3 * np.pi / n)\n", " z += np.sin(y * 3 * np.pi / n)\n", " z += x * 3 / n\n", " z += y * 5 / n\n", " return z\n", "\n", "n = 50\n", "x = np.arange(n)\n", "y = np.arange(n)\n", "X, Y = np.meshgrid(x, y)\n", "Z = f(X, Y, n)\n", "data = dict(\n", " x=X.reshape(-1),\n", " y=Y.reshape(-1),\n", " z=Z.reshape(-1))" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:27:39.210967Z", "iopub.status.busy": "2024-04-17T07:27:39.210852Z", "iopub.status.idle": "2024-04-17T07:27:39.257704Z", "shell.execute_reply": "2024-04-17T07:27:39.257273Z" } }, "outputs": [ { "data": { "text/html": [ " \n", " " ], "text/plain": [ "