Skip to content

GeoNumTP/GeoNum2017

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Resources

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)