0

我在尝试用方程
r(theta) = cos(k*theta) + C 的偏移量 C 绘制极地玫瑰时遇到了一些麻烦。我正在尝试绘制这种极地玫瑰:
http://en.wikipedia .org/wiki/Polar_coordinate_system#/media/File:Cartesian_to_polar.gif

极坐标方程可以是:
r(theta) = cos(k * theta)

r(theta) = sin(k * theta)

我要画的极地玫瑰方程是:
r(theta) = 2 + sin(6 * theta)

好的,参数方程将是:
x = C + sin(k * theta) * cos(theta)
y = C + sin(k * theta) * sin(theta)

在我的画布(绘图区域)中,我的原点不在屏幕的中心,所以我需要将玫瑰翻译到它。好吧,没什么大不了的。另一点是我需要缩放玫瑰才能看到它,否则它会太小,但仍然没问题,这解释了:100*。这是我的代码,它在 C++ btw 上:

for ( float t = 0; t < PI_2; t+= 0.01 )
{
    r = Origin.get_x() + 100*(2+(sin(6*t) * cos(t)));
    h = Origin.get_y() + 100*(2+(sin(6*t) * sin(t)));
    point(r,h);
}

我知道我做错了,因为当我添加应该是 C 常量的 +2 时,它并没有按照我想要的方式工作,它只是翻译更多并绘制没有偏移的极地玫瑰。如何防止“额外翻译”并正确绘制?

4

1 回答 1

1

x = r cos(theta)y = r sin(theta)所以你的参数方程应该是x(theta) = C * cos(theta) + sin(k*theta) * cos(theta)y(theta) = C * sin(theta) + sin(k*theta) * sin(theta)。您只是忘记分别乘以Ccos(theta)乘以sin(theta)

于 2015-04-12T05:08:58.053 回答