For the coding portion of this assignment, you will implement various expressions for discrete curvatures and surfaces normals that you will derive in the written assignment. (However, the final expressions are given below in case you want to do the coding first.) Once implemented, you will be able to visualize these geometric quantities on a mesh. For simplicity, you may assume that the mesh has no boundary.

**
Getting Started
**Please implement the following routines in

`core/geometry.js`:

`angle``dihedralAngle``vertexNormalAngleWeighted``vertexNormalSphereInscribed``vertexNormalAreaWeighted``vertexNormalGaussianCurvature``vertexNormalMeanCurvature``angleDefect``totalAngleDefect``scalarMeanCurvature``circumcentricDualArea``principalCurvatures`

**Notes **

1. The dihedral angle between the normals $N_{ijk}$ and $N_{ijl}$ of two adjacent faces $ijk$ and $ijl$ (respectively) is given by

$$ \theta_{ij} := \text{atan2}\left(\frac{e_{ij}}{\|e_{ij}\|} \cdot \left(N_{ijk} \times N_{jil}\right), N_{ijk} \cdot N_{jil}\right)$$

where $e_{ij}$ is the vector from vertex $i$ to vertex $j$.

2. The formulas for the angle weighted normal, sphere inscribed normal, area weighted normal, discrete Gaussian curvature normal and discrete mean curvature normal at vertex $i$ are

\[\begin{aligned}

N_i^\phi &:= \sum_{ijk \in F} \phi_i^{jk}N_{ijk}\\

N_i^S &:= \sum_{ijk \in F} \frac{e_{ij} \times e_{ik}} {\|e_{ij}\|^2\|e_{ik}\|^2}\\

N_i^A &:= \sum_{ijk \in F} A_{ijk}N_{ijk}\\

KN_i &= \frac 12 \sum_{ij \in E} \frac{\theta_{ij}}{\|e_{ij}\|}e_{ij}\\

HN_i &= \frac 12 \sum_{ij \in E}\left(\cot\left(\alpha_k^{ij}\right) + \cot\left(\beta_l^{ij}\right)\right)e_{ij}

\end{aligned}

\]

where $\phi_i^{jk}$ is the interior angle between edges $e_{ij}$ and $e_{ik}$, and $A_{ijk}$ is the area of face $ijk$. Note that sums are taken only over elements (edges or faces) containing vertex $i$. Normalize the final value of all your normal vectors before returning them.

3. The circumcentric dual area at vertex $i$ is given by

\[A_i := \frac 18 \sum_{ijk \in F} \|e_{ik}\|^2\cot\left(\alpha_j^{ki}\right) + \|e_{ij}\|^2\cot\left(\beta_k^{ij}\right)\]

4. The discrete scalar Gaussian curvature (also known as angle defect) and discrete scalar mean curvature at vertex $i$ are given by

\[\begin{aligned}

K_i &:= 2\pi – \sum_{ijk \in F} \phi_i^{jk}\\

H_i &:= \frac 12 \sum_{ij \in E} \theta_{ij}\|e_{ij}\|

\end{aligned}

\]

Note that these quantities are discrete 2-forms, i.e., they represent the total Gaussian and mean curvature integrated over a neighborhood of a vertex. They can be converted to pointwise quantities (i.e., discrete 0-forms at vertices) by dividing them by the circumcentric dual area of the vertex (i.e., by applying the discrete Hodge star).

5. You are required to derive expressions for the principal curvatures $\kappa_1$ and $\kappa_2$ in exercise 4 of the written assignment. Your implementation of `principalCurvatures` should return the (pointwise) minimum and maximum principal curvature values at a vertex (in that order).

**Submission Instructions**

Please rename your `geometry.js` file to `geometry.txt` and put it in a **single zip file** called `solution.zip`. This file **and** your solution to the written exercises should be submitted together in a **single email** to Geometry.Collective@gmail.com with the subject line ` DDG20A2`.