提问人:elwolv 提问时间:11/4/2023 更新时间:11/4/2023 访问量:34
如何动态创建要使用的点 point[](将计算中的 x、y 值放在 for 循环中)
how to create dynamically Point point[] to use in (place the x, y values from computation within a for loop)
问:
如何动态创建点点[] (将计算中的 x、y 值放在 for 循环中) 然后在带有点数组的 for 循环中的 LineTo GDI+ 中使用? 线到(hdc, point1, point2);
想要从以下位置创建 Point[] points 数组
for (int c = 0; c < N; c++) {
points[c]= ( radius*sin(theta*c), radius*cos(theta*c) );
}
所有尝试创建数组都有错误
找到此代码并尝试将其更改为 GDI+ C++:
https://cpp.hotexamples.com/examples/-/-/lineTo/cpp-lineto-function-examples.html
void rosette(Hdc hdc)
{
int N = 10;
float radius = 100.0;
int N = 100; float radius = 150; PI = 3.14;
Point *pointlist = new Point[N];
float theta = (2.0f * PI) / N;
float angle = theta / 2;
for (int c = 0; c < N; c++) {
pointlist[c]= (radius*sin(theta*c), radius*cos(theta*c));
}
for (int i = 0; i < N-1; i++) {
MoveTo(hdc, pointlist[i], NULL);
LineTo(hdc, pointlist[i+1]);
}
lineTo(hdc, pointlist[0]);
}
所有尝试创建数组都有错误
找到此代码并尝试将其更改为 GDI+ C++:
答: 暂无答案
评论
const
const double PI = 3.1415269;
std::list
std::list
std::vector
浮点 θ = 2.0f;
.)是否有错误?(如果没有,请简化!3.0
) (简化的)有错误吗?(如果是这样,则减少到点;点 = (3.0, 4.0);
。如果没有,请简化!等等。Point *pointlist = new Point[N];
float theta = (2.0f * PI) / N;
radius*sin(theta*c)
pointlist[c]= (3.0, 4.0);