# GeoNumTP/GeoNum2017

TP Géométrie numérique, spring 2017
Latest commit 1a004a8 Apr 6, 2017
Type Name Latest commit message Commit time
Failed to load latest commit information.
TP1
TP2 Feb 9, 2017
TP3 Feb 17, 2017
TP4
TP5 Mar 13, 2017
TP6 Mar 17, 2017
TP7 Mar 24, 2017
TP8 Mar 31, 2017
TP9 Apr 6, 2017
_assets Feb 2, 2017
viewer
.gitignore Mar 23, 2017
exportPath.sh Mar 13, 2017
setupPackages.sh Mar 23, 2017

# Géométrie numérique, spring 2017

Welcome to the github repository of the course Géométrie numérique 2017.
See course website for more details.

## Quickstart

```cd your/working/dir/
git clone https://github.com/GeoNumTP/GeoNum2017.git
cd GeoNum2017
python TP1/tp1.py```

## Syllabus

1. Bézier curves | theory | code
2. Bézier splines | theory | code
3. B-splines | theory | code
4. Subdivision curves | theory | code
5. Lane-Riesenfeld | theory | code
6. Bézier surfaces | theory | code
7. B-spline surfaces | theory | code
8. Subdivision B-surfaces | theory | code
9. Triangle mesh subdivision | theory | code

## Python

If you have no prior experience with Python whatsoever, I suggest the tutorial Learn Python in 10 minutes by Stavros Korokithakis. For longer and more complete references, see the Fast Lane to Python by Norm Matloff and, of course, the official Python 2.7 tutorial.

## NumPy

NumPy is a Python package supporting N-dimensional arrays and linear algebra operations. We'll mostly use it to manipulate datapoints stored in matrices (two-dimensional arrays). If you're not familiar with numpy, have a look at this cheatsheet.

Here are some useful numpy commands; you can test them in the `python` console.

```>>> import numpy as np

# define a 50x3 matrix of zeros
>>> Z = np.zeros([50,3])

# define a 2x3 matrix
>>> A = np.array([[1,2,3],[4,5,6]])
>>> print A
[[1 2 3]
[4 5 6]]

# define a vector with 10 evenly-spaced values between 0 and 1
>>> t = np.linspace(0,1,10)
>>> print t
[ 0.          0.11111111  0.22222222  0.33333333  0.44444444  0.55555556
0.66666667  0.77777778  0.88888889  1.        ]

# define a range
>>> i = np.arange(10)   # same as np.arange(0,10)
>>> print i
[0 1 2 3 4 5 6 7 8 9]
>>> j = np.arange(5,45,10)
>>> print j
[ 5 15 25 35]

# get dimensions of a matrix
>>> S = A.shape
>>> print S[0]  # number of rows in A
2
>>> print S[1]  # number of cols in A
3

# access a specific row
>>> print A[0,:]
[1 2 3]

# access a specific col
>>> print A[:,1]
[2 5]

# slicing: access cols 0 to 1
>>> print A[:,0:2]
[[1 2]
[4 5]]

# slicing: access cols 1 to end
>>> print A[:,1:]
[[2 3]
[5 6]]

# reshape A to have 3 rows and 2 cols
>>> B = A.reshape(3,2)
>>> print B
[[1, 2],
[3, 4],
[5, 6]]

# reshape A to have 2 cols
# number of rows is determined automatically
>>> C = B.reshape(-1,3)
>>> print C
[[1 2 3]
[4 5 6]]```

## Matplotlib

Matplotlib is a Python 2D plotting library - we'll use it to visualise 2D curves via pyplot.
Example:

```>>> import numpy as np
>>> import matplotlib.pyplot as plt

# generate random data
>>> A = np.random.rand(1000,2)
>>> x = A[:,0]
>>> y = A[:,1]

# plot blue circles
>>> plt.plot( x, y, 'bo')

# plot solid red lines
>>> plt.plot( x, y, 'r-')

# render and show the plot
>>> plt.show()

# plot dashed green lines and blue circles
>>> plt.plot(x, y, color='green', linestyle='dashed', marker='o', markerfacecolor='blue', markersize=12)```
You can’t perform that action at this time.