forked from bollu/discrete-differential-geometry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
intrinsic.py
40 lines (33 loc) · 1.07 KB
/
intrinsic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import math
from math import pi
class Mesh:
def __init__(self):
self.vertices = []
self.edges = []
self.faces = []
class Intrinsic:
def __init__(self):
self.mesh = Mesh()
# edges
self.E = {}
# half angles: E -> R
self.phi = {}
self.barycoords = {}
# angle sums
self.T = {}
def update_signpost(self, tri):
"""
Input: triangle (i, j, k) of signpost mesh S. Assumes (i, j, k)
has valid edge lengths and a valid angle phi_ij
Output: an updated signpost mesh with valid angle phi_ik
"""
(i, j, k) = tri
theta_ijk = angle(self.E[i], self.E[j], self.E[k])
# update angle
self.phi[(i, k)] = 2 * pi * theta_ijk / self.T[i]
def trace_from_vertex(self, i, r, phi):
"""
Input: A tangent vector at vertex i, given with magnitude r and an angle phi
Output: an extrinsic triangle <xyz> and a point in barycentric coordinates p
Todo: why don't we return the _intrinsic_ triangle?
"""