## ~torresjrjr/Bezier.py

Create Bezier curves in Python
~torresjrjr/bezier.py-devel

8 months ago
~torresjrjr/bezier.py-announce

8 months ago

## #Bezier.py

Create Bezier curves in Python

### #Preview plots with matplotlib

14-point 3D Bezier curve:

### #Usage

Save the main file Bezier.py into your local directory to import into your python code. Import Bezier and numpy and use. Bezier only has 1 class for now, so you can use this snippet:

```from Bezier import Bezier
import numpy as np
```

Create a Bezier curve with parameter `t` and a numpy array of inital points `points1` of any dimension. Here's a 2D example:

```t_points = np.arange(0, 1, 0.01) #................................. Creates an iterable list from 0 to 1.
points1 = np.array([[0, 0], [0, 8], [5, 10], [9, 7], [4, 3]]) #.... Creates an array of coordinates.
curve1 = Bezier.Curve(t_points, points1) #......................... Returns an array of coordinates.
```

You can plot your creations with matplotlib.

```import matplotlib.pyplot as plt

plt.figure()
plt.plot(
curve1[:, 0],   # x-coordinates.
curve1[:, 1]    # y-coordinates.
)
plt.plot(
points1[:, 0],  # x-coordinates.
points1[:, 1],  # y-coordinates.
'ro:'           # Styling (red, circles, dotted).
)
plt.grid()
plt.show()
```

The result:

See `examples.py` for more.