MCPcopy Create free account
hub / github.com/MyGUI/mygui / _getMiddleLine

Method _getMiddleLine

MyGUIEngine/src/MyGUI_PolygonalSkin.cpp:517–552  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

515 }
516
517 FloatPoint PolygonalSkin::_getMiddleLine(
518 const FloatPoint& _point1,
519 const FloatPoint& _point2,
520 const FloatPoint& _point3) const
521 {
522 // bisectrix
523 FloatPoint line1 = _point3 - _point1;
524 FloatPoint line2 = _point3 - _point2;
525 float length = len(line1.top, line1.left);
526 line1.left /= length;
527 line1.top /= length;
528 length = len(line2.top, line2.left);
529 line2.left /= length;
530 line2.top /= length;
531 FloatPoint result = line1 + line2;
532 // normalise
533 length = len(result.top, result.left);
534 if (length < 1e-6f)
535 {
536 return _getPerpendicular(_point1, _point2);
537 }
538 result.left /= length;
539 result.top /= length;
540
541 float cos = result.left * line1.left + result.top * line1.top;
542 float angle = std::acos(cos);
543
544 // too sharp angle
545 if (std::fabs(angle) < 1e-6f /*< 0.2f*/)
546 return {};
547
548 float width = mLineWidth / 2 / std::sin(angle);
549 result.left *= width;
550 result.top *= width;
551 return result;
552 }
553
554} // namespace MyGUI

Callers

nothing calls this directly

Calls 1

lenFunction · 0.70

Tested by

no test coverage detected