计算机图形学实现上图效果:
1、首先绘制金刚石图案(其中分成几等份,可以自定义),得到十个点的坐标
void C金刚石View::ReadPoint()
{
int n = 10, i;
//角度也平分,每个角度为2PI/n;10个点分成10份
double t = 3.14159 * 2 / n;
double x0 = 0.0, y0 = 0.0;
//double t = PI * 2 / n;
for (i = 0; i < n; i++)
{
p[i].x = r*cos(i*t)+x0;
p[i].y = r*sin(i*t) + y0;
}
}
2、将得到的点依次连接,并将二维变换的平移与旋转叠加,获得变换后的点,再次绘制图形
void C金刚石View::DrawObject(CDC *pDC)
{
CPen newPen ,*pOldPen;
newPen.CreatePen(PS_SOLID, 1, RGB(255, 77, 0));
pOldPen = pDC->SelectObject(&newPen);
int i, j,n=10;
for (i = 0; i < n - 1; i++)
for (j = i + 1; j <=