The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.
Become a Premium Member and unlock a new, free course in leading technologies each month.
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
void RoundPolygonVertices( VERTEXES& vcVertexes, double dRound )
{
VERTEXES vt;
CVertex v0,v1;
long lCount = vcVertexes.size();
for( int i = 0; i < lCount; ++i )
{
if(i)
{
double dLength = Magnitude(vcVertexes[i], vcVertexes[i-1]);
double slope=(vcVertexes[i].dY-vcVertexes[i-1].dY)/(vcVertexes[i].dX-vcVertexes[i-1].dX);
double slopeAngle;
if(!_isnan(slope))
slopeAngle=atan(slope);
else
{
slope=0;
slopeAngle=0;
}
if( dLength > 0.0 && dRound > 0.0 )
{
if(fmod( dLength, dRound) > 0)
{
double dUpper, dLower;
dLower = floor(dLength / dRound) * dRound;
dUpper = dLower+dRound;
if((dLength-dLower) >= (dUpper-dLength))
dLength=dUpper;
else
dLength=dLower;
}
v1=vcVertexes[i]-vcVertexes[i-1];
if(v1.dX)
v1.dX=v1.dX/fabs(v1.dX);
if(v1.dY)
v1.dY=v1.dY/fabs(v1.dY);
v1.dY=v1.dY*fabs(sin(slopeAngle)*dLength);
v1.dX=v1.dX*fabs(cos(slopeAngle)*dLength);
v0=v1+v0;
}
vt.push_back(v0);
}
else
vt.push_back( v0 );
}
vcVertexes.clear();
vcVertexes.insert( vcVertexes.begin(), vt.begin(), vt.end() );
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.