src/geometry.h

changeset 108
94c92c923713
parent 106
128efb9d148b
child 109
40a1cf2f38f5
equal deleted inserted replaced
107:02f142b399b1 108:94c92c923713
101 struct NPolygon 101 struct NPolygon
102 { 102 {
103 std::vector<glm::vec3> points; 103 std::vector<glm::vec3> points;
104 }; 104 };
105 105
106 inline bool isclose(const glm::vec3& a, const glm::vec3& b) 106 inline constexpr bool isclose(const glm::vec3& a, const glm::vec3& b)
107 { 107 {
108 return qFuzzyCompare(a.x, b.x) 108 return qFuzzyCompare(a.x, b.x)
109 and qFuzzyCompare(a.y, b.y) 109 and qFuzzyCompare(a.y, b.y)
110 and qFuzzyCompare(a.z, b.z); 110 and qFuzzyCompare(a.z, b.z);
111 } 111 }
112
113 struct CircleF
114 {
115 QPointF center;
116 qreal radius;
117 };
118
119 /**
120 * @param center
121 * @param radius
122 * @returns a QRectF that encloses the specified circle
123 */
124 inline constexpr QRectF inscribe(const CircleF& circle)
125 {
126 return {
127 circle.center.x() - circle.radius,
128 circle.center.y() - circle.radius,
129 circle.radius * 2,
130 circle.radius * 2
131 };
132 }
112 } 133 }

mercurial