MCPcopy Create free account
hub / github.com/OpenBoard-org/OpenBoard / heightAtPosition

Method heightAtPosition

src/tools/UBGraphicsTriangle.cpp:160–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158}
159
160qreal UBGraphicsTriangle::heightAtPosition(qreal position)
161{
162 /* B____C
163 | /
164 D|_/E <-- triangle height at given position
165 |/
166 A
167 */
168 qreal AD;
169 switch(mOrientation)
170 {
171 case BottomLeft:
172 AD = QLineF(rect().bottomRight(), QPointF(position, rotationCenter().y())).length();
173 break;
174 case TopLeft:
175 AD = QLineF(rect().topRight(), QPointF(position, rotationCenter().y())).length();
176 break;
177 case TopRight:
178 AD = QLineF(rect().topLeft(), QPointF(position, rotationCenter().y())).length();
179 break;
180 case BottomRight:
181 AD = QLineF(rect().bottomLeft(), QPointF(position, rotationCenter().y())).length();
182 break;
183 }
184
185 qreal AB = rect().width();
186 qreal BC = rect().height();
187 return (AD * BC / AB); //DE
188}
189
190
191QRectF UBGraphicsTriangle::bounding_Rect() const

Callers

nothing calls this directly

Calls 3

lengthMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected