For the coding portion of your first assignment, you will implement the discrete exterior calculus (DEC) operators $\star_0, \star_1, \star_2, d_0$ and $d_1$. Once implemented, you will be able to apply these operators to a scalar function (as depicted above) by pressing the “$\star$” and “$d$” button in the viewer. The diagram shown above will be updated to indicate what kind of differential *k*-form is currently displayed. These basic operations will be the starting point for many of the algorithms we will implement throughout the rest of the class; the visualization (and implementation!) should help you build further intuition about what these operators mean and how they work

**Getting Started**

- For this assignment, you need to implement the following routines:
- in
`core/geometry.js``cotan``barycentricDualArea`

- in
`core/discrete-exterior-calculus.js``buildHodgeStar0Form``buildHodgeStar1Form``buildHodgeStar2Form``buildExteriorDerivative0Form``buildExteriorDerivative1Form`

- in

In practice, a simple and efficient way to compute the cotangent of the angle $\theta$ between two vectors $u$ and $v$ is to use the cross product and the dot product rather than calling any trigonometric functions directly; we ask that you implement your solution this way. (**Hint**: how are the dot and cross product of two vectors related to the cosine and sine of the angle between them?)

In case we have not yet covered it in class, the *barycentric dual area* associated with a vertex $i$ is equal to one-third the area of all triangles $ijk$ touching $i$.

*EDIT: * You can compute the ratio of dual edge lengths to primal edge lengths using the *cotan formula*, which can be found on Slide 28 of the Discrete Exterior Calculus lecture, or in exercise 36 of the notes (you don’t have to do the exercise for this homework).

**Submission Instructions**

Please rename your `geometry.js` and `discrete-exterior-calculus.js` files to `geometry.txt` and `discrete-exterior-calculus.txt` (respectively) and submit them in a **single zip file** called `solution.zip` by email to Geometry.Collective@gmail.com.

For the exterior derivative functions, where do we get the orientations of the edges and the faces so that we know how to sum up the vertices/edges, respectively? Or am I just missing a function or parameter in the Geometry class that keeps track of this?

Never mind, I was stupid and forgot about Halfedges.

But you can’t assume that halfedges and edges have the same orientation, so I’m still not sure how to tell…

For the cotan function, we are looking for the angle “opposite to” the halfedge given. What exactly does “opposite to” mean?

Imagine a triangle. The angle opposite to an edge is the angle formed by the two other edges of the triangle.

Is this the corner stored in the half edge? Does the mesh contain only triangles? I’m confused about how to find the two edges forming the angle if the mesh contains polygons besides triangles.

The meshes are all triangle meshes.

Thanks. I found that only the dual mesh is allowed to be a non-triangle polygon mesh and the Hodge star operator only applied to the primary mesh. It’s now clear.

What about the case where the edge is shared by two triangles? Which angle do we refer to in this case in terms of calculating the cotan?

You’re given a halfedge as input, so this shouldn’t be ambiguous.

What should the length of the dual of a boundary edge be?

I believe the twin points to null and the value will be 0. If you just use the standard formula we provided, you will not run into any issue. Many meshes we use describing 3D data are without boundary, so this is not an issue there.

Are we supposed to use barycentric dual or circumcentric dual for the Hodge star matrices? We write the barycentric functoin but Slide 28 is about the circumcentric dual.

For this assignment we are using barycentric. However either can be used with varying advantages/disadvantages.