src/linetypes/quadrilateral.cpp

changeset 1390
3eace926af7f
parent 1326
69a90bd2dba2
child 1402
8bbf2af8c3f5
--- a/src/linetypes/quadrilateral.cpp	Sat May 26 17:28:15 2018 +0300
+++ b/src/linetypes/quadrilateral.cpp	Wed May 30 22:31:06 2018 +0300
@@ -55,3 +55,21 @@
 {
 	return LDObjectType::Quadrilateral;
 }
+
+/*
+ * Returns whether or not this quadrilateral is co-planar.
+ */
+bool LDQuadrilateral::isCoPlanar() const
+{
+	return planeAngle() < 0.001745329;
+}
+
+/*
+ * Returns the angle between the two planes in this quadrilateral.
+ */
+qreal LDQuadrilateral::planeAngle() const
+{
+	QVector3D vec_1 = QVector3D::crossProduct(vertex(2) - vertex(1), vertex(0) - vertex(1));
+	QVector3D vec_2 = QVector3D::crossProduct(vertex(0) - vertex(3), vertex(2) - vertex(3));
+	return vectorAngle(vec_1, vec_2);
+}

mercurial