极地玫瑰 2D 偏移

Polar Rose 2D offset

我在尝试用等式的偏移量 C 绘制极地玫瑰图时遇到了一些麻烦
r(theta) = cos(k*theta) + 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)

在我的Canvas(绘图区)中,我的原点不在屏幕中心,所以我需要将玫瑰平移到它。好的,没什么大不了的。另一点是我需要缩放玫瑰以使其可见,否则它会太小,但仍然没问题,这解释了:100*。这是我的代码,它是在 C++ 上顺便说一句:

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 时,它没有按照我想要的方式工作,它只是翻译更多并绘制了没有偏移的极地玫瑰。如何防止 "extra translation" 并正确绘制?

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)。您只是忘记分别将 C 乘以 cos(theta)sin(theta)