{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\nOptimized Alpha Example\n=======================\n\nUsing the optimized alpha function for obtaining the alpha parameter.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import alphashape\nimport matplotlib.pyplot as plt\nfrom descartes import PolygonPatch\n\n# Define input points\npoints = [(0., 0.), (0., 1.), (1., 1.), (1., 0.),\n          (0.5, 0.25), (0.5, 0.75), (0.25, 0.5), (0.75, 0.5)]\n\n# Determine the optimized alpha parameter\nalpha = alphashape.optimizealpha(points)\n\n# Generate the alpha shape\nalpha_shape = alphashape.alphashape(points, alpha)\n\n# Initialize plot\nfig, ax = plt.subplots()\n\n# Plot input points\nax.scatter(*zip(*points))\n\n# Plot alpha shape\nax.add_patch(PolygonPatch(alpha_shape, alpha=.2))\n\nplt.show()"
      ]
    }
  ],
  "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.8.12"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}