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() );
Title | # Comments | Views | Activity |
---|---|---|---|
move a line in eclipse | 3 | 60 | |
Modbus - whats the maximum I can store in one register? | 4 | 74 | |
Execute multiple curl cmds with sleep and send output to file | 10 | 80 | |
Dialogbox API leak? | 18 | 59 |
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
14 Experts available now in Live!