Skip to content

Instantly share code, notes, and snippets.

@uetchy
Created May 14, 2018 02:43
Show Gist options
  • Save uetchy/c84a0068e099d95418fb13fd453873a4 to your computer and use it in GitHub Desktop.
Save uetchy/c84a0068e099d95418fb13fd453873a4 to your computer and use it in GitHub Desktop.
Bezier curve from scratch
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"from math import factorial\n",
"import numpy as np\n",
"from functools import reduce\n",
"import matplotlib.pyplot as plt\n",
"%matplotlib inline"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"class Bezier:\n",
"\n",
" def __init__(self, ndim, points):\n",
" self.ndim = ndim\n",
" self.points = np.array(points)\n",
"\n",
" def combination(self, n, r):\n",
" return factorial(n) / factorial(r)\n",
"\n",
" def bernstein(self, n, i, t):\n",
" '''\n",
" B_i^n = \\binom ni (1-t)^{n-i} t^i\n",
" '''\n",
" return self.combination(n, i) * (1 - t)**(n - i) * t**i\n",
"\n",
" def R(self, n, t, p):\n",
" '''\n",
" R(T) = \\sum^n_{i=0} B_i^n(t) P_i\n",
" '''\n",
" return reduce(lambda s, i: s + self.bernstein(n, i, t) * p[i],\n",
" range(n + 1))\n",
"\n",
" def render(self, t):\n",
" xr = self.R(self.ndim, t, self.points.T[0])\n",
" yr = self.R(self.ndim, t, self.points.T[1])\n",
" return (xr, yr)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXUAAAD8CAYAAACINTRsAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3XeY1NXZ//H3vTRpgiiCioiPKCrYcH/Gggr4KJDHgoiAx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ZNTezMWb2iplNMbMWsTNVlpntZGYvmdnM1HvZLnamqjCz2mb2oZn1iZ2lKszs+dTP/LQC+HkpMrNLzWySmZ2WzdfK+6JezsHXSdQAeDR2iAxYCVweQjgaeBK4NnKeqigFTgkhHAzMAHpHzlNV/YFFsUNkwKoQQsfU7c7YYaroTvwo0K4hhKey+UJ5X9TZ+sHXiRNCGI8XxEQLISwLIWwqHDOA5jHzVEUIYX0IYamZNQRaAm/FzlRZqU+y7YFXY2epitQhPJs9HjNpzGwfYGd8cDrFzA7I5usloahv7eBryQ8d8F+4iWVm5+P/tj4AZkeOUxW3k+xPTZtsD+xvZm+b2Z1mVit2oCo4Gf+Efgb+KWpoNl8sCUV9awdfS2RmtjPQExgcO0tVhBAGAbsATYErIsepFDPrCvw9hDA/dpaqCiGUhhD2wQcM9fFimFS7AoNDCGtDCO8Aa7N53SYJRX1rB19LRGZWHx919AshrIgcp8pCCEuAR4BjY2eppJ5ABzMbB/QBrjKzzpEzVUkIYS2+vvvg2FmqYCmwW5nvG5HFgWkSivqPDr6OnEf4zy/YQcCdIYSPY+epCjNrlJrDBegGzImZp7JCCOeHEP4vhNAdGAncFUKYEjtXZZhZ/dSKkSKgBwm+zoHXrBNS72dP4N8hhO+y9WLlHjwd2xYOvpb4rsBHtDuZ2U3AtyGEHpEzVVZH4DozW4uvGrkobhzBf7neiE+3vk5Cp8RSpgJH4u9jNdA3my+mHaUiIgUkCdMvIiKSJhV1EZECoqIuIlJAVNRFRAqIirqISAFRURcRKSAq6iIiBURFXUSkgPx/awxzrIJgRzgAAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"bezier_points = np.array([(0, 0), (1, 3), (5, 3), (6, 0)])\n",
"renderer = Bezier(3, bezier_points)\n",
"rpoints = np.array([renderer.render(tn * 0.01) for tn in range(100)])\n",
"rpoints = np.append(rpoints, [bezier_points[-1]], axis=0)\n",
"plt.plot(rpoints.T[0], rpoints.T[1], 'b')\n",
"plt.plot(bezier_points.T[0], bezier_points.T[1], 'o')\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment