MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / OffsetPoint

Method OffsetPoint

TheForceEngine/TFE_Polygon/clipper.cpp:4131–4172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4129//------------------------------------------------------------------------------
4130
4131void ClipperOffset::OffsetPoint(int j, int& k, JoinType jointype)
4132{
4133 //cross product ...
4134 m_sinA = (m_normals[k].X * m_normals[j].Y - m_normals[j].X * m_normals[k].Y);
4135 if (std::fabs(m_sinA * m_delta) < 1.0)
4136 {
4137 //dot product ...
4138 double cosA = (m_normals[k].X * m_normals[j].X + m_normals[j].Y * m_normals[k].Y );
4139 if (cosA > 0) // angle => 0 degrees
4140 {
4141 m_destPoly.push_back(IntPoint(Round(m_srcPoly[j].X + m_normals[k].X * m_delta),
4142 Round(m_srcPoly[j].Y + m_normals[k].Y * m_delta)));
4143 return;
4144 }
4145 //else angle => 180 degrees
4146 }
4147 else if (m_sinA > 1.0) m_sinA = 1.0;
4148 else if (m_sinA < -1.0) m_sinA = -1.0;
4149
4150 if (m_sinA * m_delta < 0)
4151 {
4152 m_destPoly.push_back(IntPoint(Round(m_srcPoly[j].X + m_normals[k].X * m_delta),
4153 Round(m_srcPoly[j].Y + m_normals[k].Y * m_delta)));
4154 m_destPoly.push_back(m_srcPoly[j]);
4155 m_destPoly.push_back(IntPoint(Round(m_srcPoly[j].X + m_normals[j].X * m_delta),
4156 Round(m_srcPoly[j].Y + m_normals[j].Y * m_delta)));
4157 }
4158 else
4159 switch (jointype)
4160 {
4161 case jtMiter:
4162 {
4163 double r = 1 + (m_normals[j].X * m_normals[k].X +
4164 m_normals[j].Y * m_normals[k].Y);
4165 if (r >= m_miterLim) DoMiter(j, k, r); else DoSquare(j, k);
4166 break;
4167 }
4168 case jtSquare: DoSquare(j, k); break;
4169 case jtRound: DoRound(j, k); break;
4170 }
4171 k = j;
4172}
4173//------------------------------------------------------------------------------
4174
4175void ClipperOffset::DoSquare(int j, int k)

Callers

nothing calls this directly

Calls 3

IntPointClass · 0.85
RoundFunction · 0.85
push_backMethod · 0.80

Tested by

no test coverage detected