【问题标题】:Polar Rose 2D offsetPolar Rose 2D 偏移
【发布时间】:2015-04-12 05:04:24
【问题描述】:

我在尝试用方程的偏移量 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)

在我的画布(绘图区域)中,我的原点不在屏幕的中心,所以我需要将玫瑰翻译到它。好吧,没什么大不了的。另一点是我需要缩放玫瑰才能看到它,否则它会太小,但仍然没问题,这解释了: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 时,它并没有按照我想要的方式工作,它只是翻译更多并绘制没有偏移的极地玫瑰。如何防止“额外翻译”并正确绘制?

【问题讨论】:

    标签: c++ 2d polar-coordinates parametric-equations


    【解决方案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)。您只是忘了将C 分别乘以cos(theta)sin(theta)

    【讨论】:

    • 非常感谢! :D 对不起,但我没有足够的声誉来投票给你的答案,有没有办法把它作为“正确答案”?
    猜你喜欢
    • 2021-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-05
    • 2020-09-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多