blob: 671650296cfdb2fcd9697edc24e093d88d65c31d (
plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
// This code is in the public domain -- castanyo@yahoo.es
#include "nvmesh.h" // pch
#include "Edge.h"
#include "Vertex.h"
#include "nvmath/Vector.inl"
using namespace nv;
using namespace HalfEdge;
Vector3 Edge::midPoint() const
{
return (to()->pos + from()->pos) * 0.5f;
}
float Edge::length() const
{
return ::length(to()->pos - from()->pos);
}
// Return angle between this edge and the previous one.
float Edge::angle() const {
Vector3 p = vertex->pos;
Vector3 a = prev->vertex->pos;
Vector3 b = next->vertex->pos;
Vector3 v0 = a - p;
Vector3 v1 = b - p;
return acosf(dot(v0, v1) / (nv::length(v0) * nv::length(v1)));
}
bool Edge::isValid() const
{
// null face is OK.
if (next == NULL || prev == NULL || pair == NULL || vertex == NULL) return false;
if (next->prev != this) return false;
if (prev->next != this) return false;
if (pair->pair != this) return false;
return true;
}
/*
Edge * Edge::nextBoundary() {
nvDebugCheck(this->m_pair == NULL);
}
Edge * Edge::prevBoundary() {
nvDebugCheck(this->m_pair == NULL);
}
*/
|