# Assignment 1 (Coding): Exterior Calculus (Due 2/25)

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:
1. in core/geometry.js
1. cotan
2. barycentricDualArea
2. in core/discrete-exterior-calculus.js
1. buildHodgeStar0Form
2. buildHodgeStar1Form
3. buildHodgeStar2Form
4. buildExteriorDerivative0Form
5. buildExteriorDerivative1Form

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.

## 14 thoughts on “Assignment 1 (Coding): Exterior Calculus (Due 2/25)”

1. svsalem says:

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?

1. svsalem says:

Never mind, I was stupid and forgot about Halfedges.

1. Ninae says:

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

2. Liu Qiangdong says:

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

1. Daniel Li says:

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

1. hawaiii says:

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.

1. hawaiii says:

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.

2. fpou says:

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?

1. Alex says:

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

3. lykospirit says:

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

1. Daniel Li says:

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.

4. xTheBHox says:

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.

1. Alex says:

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