diff options
Diffstat (limited to 'thirdparty/thekla_atlas/nvmesh/halfedge/Edge.cpp')
-rw-r--r-- | thirdparty/thekla_atlas/nvmesh/halfedge/Edge.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/thirdparty/thekla_atlas/nvmesh/halfedge/Edge.cpp b/thirdparty/thekla_atlas/nvmesh/halfedge/Edge.cpp new file mode 100644 index 0000000000..671650296c --- /dev/null +++ b/thirdparty/thekla_atlas/nvmesh/halfedge/Edge.cpp @@ -0,0 +1,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); + +} +*/ + + |