Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.
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
Title | # Comments | Views | Activity |
---|---|---|---|
FizzBuzz challenge | 9 | 80 | |
sumHeights2 challenge | 7 | 102 | |
ASP.NET C# MessageBox.Show Showing a modal dialog box or form when the application ... | 2 | 119 | |
How to Correctly derive class from CWinThread in MFC | 4 | 34 |
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
12 Experts available now in Live!