Assignment 01
TIN + Voronoi diagram
Deadline is 2023-11-28@17:00
Late submission? 10% will be removed for each day that you are late (3 days max)
This is an individual assignment
- What you are given to start
- How to use the program
- What you have to do
- Good to know
- Marking
- What to submit and how to submit it
The aim of this assignment is to implement some functions related to the Delaunay triangulation and the Voronoi diagram.
You have to implement the 3 following operations:
- extracting the VD from the DT
- calculating the area of a given Voronoi cell
- implementing linear interpolation in a TIN
What you are given to start
Code is in the /hw/01/
folder of the TUDelft GitLab repository of the course (you need to login with your NetID).
We give you the skeleton of the Python program:
geo1015_hw01.py
is the main(). You are not allowed to modify this file!interface.py
is what controls the interface. You are not allowed to modify this file!mycode_hw01.py
is where all your code should go. There are 3 functions defined there and you must complete them. You are not allowed to change the input parameters. You are however allowed to add any other functions you want in that unit (please do not include any other unit you code, add your code to that single file). You are only allowed to import modules from the Python standard library (anything you installed throughpip
is thus not allowed).
To run the code you first need to install the following libraries:
pip install -U numpy
pip install -U startinpy
pip install -U rasterio
pip install -U matplotlib
pip install -U pillow
and then:
python geo1015_hw01.py
this starts a window that looks like the one above.
How to use the program
It loads a terrain (from Tasmania, Australia), and when you click you insert new points that get assigned the elevation of the terrain. As you click the DT is displayed and gets updated.
===== USAGE =====
keyboard 'd' to toggle between DT and VD.
keyboard 'i' to toggle between insertion and interpolation.
keyboard 'q' to quit the program.
keyboard 'r' to reset the DT/VD to an empty one.
=================
What you have to do
You have to write the code for the 3 functions in mycode_hw01.py
:
get_voronoi_edges()
get_area_voronoi_cell()
interpolate_tin()
Observe that you are not allowed to use directly the function interpolate()
in startinpy for the TIN-linear interpolation, you have to code the function yourself.
But you can test your results with those given by startinpy.
Good to know
- how startinpy works is well documented
- the file
mycode_hw01.py
gives you hints, read its content - the time it takes for your program to terminate has no influence on the marks you’ll get
- only the Voronoi cells that are bounded (ie not on the convex hull of the dataset) need to be drawn
- the marking will be automatic, I will test your
mycode_hw01.py
with several of my inputs (others than those given) and verify whether you return the correct values and handle all the cases - therefore, test your code with different inputs, by building them manually and including your
mycode_hw01.py
, eg:
from my_code_hw01 import Tin
import numpy as np
tin = Tin()
tin.insert_one_pt(0., 0., 1.)
tin.insert_one_pt(1., 0., 2.)
tin.insert_one_pt(1., 1., 3.)
tin.insert_one_pt(0., 1., 4.)
vi_last = tin.number_of_vertices()
print(tin.get_area_voronoi_cell(3))
Marking
Criterion | Points |
---|---|
followed all rules and compiles/runs without modifications | 2.5 |
drawing Voronoi cells | 2.5 |
area Voronoi cell | 2.5 |
interpolation TIN linear | 2.5 |
What to submit and how to submit it
You have to submit one file: my_code_hw01.py
.
Don’t forget to add your name and student-number at the top of the tile, as the comments tell you.
Oh, and no report is necessary.
Upload the file to this Dropbox page.
[last updated: 2023-11-07 08:21]