13 namespace geometry_utility
19 resultVerticiesPos.resize(_size);
20 for (
size_t i = 0; i < _size; ++i)
22 resultVerticiesPos[i] = _baseVerticiesPos[i];
30 return resultVerticiesPos;
36 int invert = (_side ==
Right || _side ==
Bottom) ? -1 : 1;
37 for (
size_t i = 0; i < _verticies.size(); ++i)
40 FloatPoint& v1 = _verticies[(i + 1) % _verticies.size()];
46 if (invert * v0.
left >= invert * _sideCoord && invert * v1.
left >= invert * _sideCoord)
47 newVerticies.push_back(v0);
49 else if (invert * v0.
left >= invert * _sideCoord && invert * v1.
left < invert * _sideCoord)
51 newVerticies.push_back(v0);
52 float c = (v0.
left - _sideCoord) / (_sideCoord - v1.
left);
53 newVerticies.push_back(
FloatPoint((
float)_sideCoord, (v0.
top + c * v1.
top) / (c + 1)));
56 else if (invert * v0.
left <= invert * _sideCoord && invert * v1.
left > invert * _sideCoord)
58 float c = (v0.
left - _sideCoord) / (_sideCoord - v1.
left);
59 newVerticies.push_back(
FloatPoint((
float)_sideCoord, (v0.
top + c * v1.
top) / (c + 1)));
66 if (invert * v0.
top >= invert * _sideCoord && invert * v1.
top >= invert * _sideCoord)
67 newVerticies.push_back(v0);
69 else if (invert * v0.
top >= invert * _sideCoord && invert * v1.
top < invert * _sideCoord)
71 newVerticies.push_back(v0);
72 float c = (v0.
top - _sideCoord) / (_sideCoord - v1.
top);
73 newVerticies.push_back(
FloatPoint((v0.
left + c * v1.
left) / (c + 1), (
float)_sideCoord));
76 else if (invert * v0.
top <= invert * _sideCoord && invert * v1.
top > invert * _sideCoord)
78 float c = (v0.
top - _sideCoord) / (_sideCoord - v1.
top);
79 newVerticies.push_back(
FloatPoint((v0.
left + c * v1.
left) / (c + 1), (
float)_sideCoord));
86 _verticies = newVerticies;