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



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:

  1. extracting the VD from the DT
  2. calculating the area of a given Voronoi cell
  3. 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:

  1. geo1015_hw01.py is the main(). You are not allowed to modify this file!
  2. interface.py is what controls the interface. You are not allowed to modify this file!
  3. 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 through pip 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:

  1. get_voronoi_edges()
  2. get_area_voronoi_cell()
  3. 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

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]