3
我开始了一个完美的圆圈,然后我需要旋转和缩放免费无松弛的椭圆特点:如何基于四个旋转和缩放的点绘制椭圆?
我想知道是否有描述扭曲像一个椭圆形的方式只基于余弦和正弦。
我有这样的代码:
float centerX = 100;
float centerY = 100;
float radiusX = 100;
float radiusY = 100;
float rotation = PI;
float res = 30;
for (int i = 0; i < res; i++) {
//find the point in space for the circle resolution
float angle = (float)i/res * TWO_PI;
float x = radiusX * cos(angle);
float y = -radiusY * sin(angle);
//rotate the point
float s = sin(rotation);
float c = cos(rotation);
// translate point to origin:
p->x -= centerX;
p->y -= centerY;
float xnew = p->x * c - p->y * s;
float ynew = p->x * s + p->y * c;
// translate point back
x = xnew + centerX;
y = ynew + centerY;
//apply X Y
}
此代码只能代表相同椭圆忽略旋转和比例之间的关系:
我想看看仿射变换覆盖所有你想在同一时间做的事情:我知道平移,旋转和缩放 – WorldSEnder
它是不相关的你的问题,但缩放之前旋转圆的优点是什么? – jxh
谢谢@WorldSEnder,我现在试图使用椭圆的焦点,这看起来很有保证。 –