@@ -18,25 +18,25 @@ namespace shapes
1818
1919namespace util
2020{
21- // Use this convetion e_i = v_{i+2}-v_{i+1}. vertex index is modulo by 3.
22- template <typename float_t>
23- vector <float_t, 3 > anglesFromTriangleEdge (const vector <float_t, 3 > e0, vector <float_t, 3 > e1, const vector <float_t, 3 > e2)
24- {
25- // Calculate this triangle's weight for each of its three m_vertices
26- // start by calculating the lengths of its sides
27- const float_t a = hlsl::dot (e0, e0);
28- const float_t asqrt = hlsl::sqrt (a);
29- const float_t b = hlsl::dot (e1, e1);
30- const float_t bsqrt = hlsl::sqrt (b);
31- const float_t c = hlsl::dot (e2, e2);
32- const float_t csqrt = hlsl::sqrt (c);
21+ // Use this convetion e_i = v_{i+2}-v_{i+1}. vertex index is modulo by 3.
22+ template <typename float_t>
23+ vector <float_t, 3 > anglesFromTriangleEdges (const vector <float_t, 3 > e0, vector <float_t, 3 > e1, const vector <float_t, 3 > e2)
24+ {
25+ // Calculate this triangle's weight for each of its three m_vertices
26+ // start by calculating the lengths of its sides
27+ const float_t a = hlsl::dot (e0, e0);
28+ const float_t asqrt = hlsl::sqrt (a);
29+ const float_t b = hlsl::dot (e1, e1);
30+ const float_t bsqrt = hlsl::sqrt (b);
31+ const float_t c = hlsl::dot (e2, e2);
32+ const float_t csqrt = hlsl::sqrt (c);
3333
34- const float_t angle0 = hlsl::acos ((b + c - a) / (2.f * bsqrt * csqrt));
35- const float_t angle1 = hlsl::acos ((-b + c + a) / (2.f * asqrt * csqrt));
36- const float_t angle2 = hlsl::numbers::pi<float_t> - (angle0 + angle1);
37- // use them to find the angle at each vertex
38- return vector <float_t, 3 >(angle0, angle1, angle2);
39- }
34+ const float_t angle0 = hlsl::acos ((b + c - a) / (2.f * bsqrt * csqrt));
35+ const float_t angle1 = hlsl::acos ((-b + c + a) / (2.f * asqrt * csqrt));
36+ const float_t angle2 = hlsl::numbers::pi<float_t> - (angle0 + angle1);
37+ // use them to find the angle at each vertex
38+ return vector <float_t, 3 >(angle0, angle1, angle2);
39+ }
4040}
4141
4242}
0 commit comments