beginning to believe
This commit is contained in:
34
src/util.h
34
src/util.h
@ -1,6 +1,11 @@
|
||||
#ifndef UTIL_H
|
||||
#define UTIL_H
|
||||
|
||||
#include "my_mesh.h"
|
||||
|
||||
#include <QVector3D>
|
||||
#include <QtMath>
|
||||
|
||||
|
||||
template <typename Mesh>
|
||||
class HalfedgeLoopRange {
|
||||
@ -36,4 +41,33 @@ class ConstHalfedgeLoopRange {
|
||||
};
|
||||
|
||||
|
||||
QDebug operator<<(QDebug dbg, const Point &p);
|
||||
|
||||
|
||||
/* Returns the angle between the vector from p2 to p1 and the vector
|
||||
* from p2 to p3. */
|
||||
template <typename Point>
|
||||
qreal angle_between(Point p1,
|
||||
Point p2,
|
||||
Point p3) {
|
||||
Point vec_a = p1 - p2;
|
||||
Point vec_b = p3 - p2;
|
||||
QVector3D a(vec_a[0], vec_a[1], vec_a[2]);
|
||||
QVector3D b(vec_b[0], vec_b[1], vec_b[2]);
|
||||
return qAcos(QVector3D::dotProduct(a.normalized(), b.normalized()));
|
||||
}
|
||||
|
||||
|
||||
template <typename Point>
|
||||
qreal triangle_area(Point p1,
|
||||
Point p2,
|
||||
Point p3) {
|
||||
Point vec_a = p1 - p2;
|
||||
Point vec_b = p3 - p2;
|
||||
QVector3D a(vec_a[0], vec_a[1], vec_a[2]);
|
||||
QVector3D b(vec_b[0], vec_b[1], vec_b[2]);
|
||||
return QVector3D::crossProduct(a, b).length() / 2.;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user