idk some changes, shit's still fucked
This commit is contained in:
19
src/util.h
19
src/util.h
@ -47,27 +47,22 @@ 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) {
|
||||
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()));
|
||||
return qAcos(vec_a.dot(vec_b) / (vec_a.norm() * vec_b.norm()));
|
||||
}
|
||||
|
||||
|
||||
template <typename Point>
|
||||
qreal triangle_area(Point p1,
|
||||
Point p2,
|
||||
Point p3) {
|
||||
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.;
|
||||
return vec_a.cross(vec_b).norm() / 2.;
|
||||
}
|
||||
|
||||
|
||||
qreal cotan(const qreal x);
|
||||
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user