polygonal 4-point subdivision, Homework 5

subdivided_polygonFor your new Homework you can forget about HalfEdge and recall/refresh your knowledge about jReality-Geometry-tutorials and further the Plugin-tutorials.

Copy the package mathvis.subdivpolygon, with its classes:

  • DragPointSet
  • LabeledSpinner
  • PointSequence
  • SubdividedPolygon
  • SubdividedPolygonPlugin
  • SubdividerDemo

Edit the SubdividedPolygon.class and write the subdivide-Method (check the TODO statement). For that you should use the rekursive 4-Point Subdivision Scheme.

4-Point-Subdivision:

Each new point $q_i \in Q$ beween two base-points $p_i, p_{i+1} \in P$ will be added the following way:

$q_i = \tfrac{1}{16} ( 9*(p_i + p_{i+1} ) – p_{i-1} – p_{i+2})$

Afterwards the set $P \cup Q$  are your new base-points. Apply the next subdivision step on the new base-points-set. Do this until you reach your choosen subdivision level.

Boundary:

Extend the GUI with a RadioButton to toggle that the polygon is closed or not.

If you handle an open polygon $(p_1, … p_n)$ the boundary-conditions are the following:

for the first point $p_{0}=2*p_1-p_2$ and for the last point $p_{n+1} = 2*p_n – p_{n-1}$