如何从点创建椭圆 [英] How to make a ellipse from points

查看:171
本文介绍了如何从点创建椭圆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  float x = CIRCLE_RADIUS *(float)Math.sin(2f * Math.PI * drawSquareIndex / ITEMS_COUNT + angle)* 1.75f; 

其中x - 是圆圈项目的X点。



我有一个圈子。





但我想在椭圆上绘制图片。什么公式我需要使用?





我该怎么做?

对质量抱歉。您可以使用椭圆参数公式 a = b cirle 的情况):

  x = a * cos(t)
y = b * sin(t)
t = 0..2 * PI

您的情况

  //伪代码
for(double t = 0; t <= 2 * PI; t + = 0.001){// < - 或者不同的步骤
double x = RadiusX * Math.Cos(t);
double y = RadiusY * Math.Sin(t);

Paint(x,y);
}


Now i draw pictures in circle by formula :

     float x = CIRCLE_RADIUS *  (float) Math.sin(2f * Math.PI * drawSquareIndex / ITEMS_COUNT + angle) * 1.75f;

where x - is a X point of circle item.

And i have a circle.

but i want to draw pictures on ellipse. What the formula i need to use?

How i can do that?

P.S. sorry about quality. Make a question from phone.

解决方案

You can use parametric ellipse equaition (a = b is a case of cirle):

x = a * cos(t)
y = b * sin(t)
t = 0..2*PI

In your case

  // Pseudo code
  for (double t = 0; t < 2 * PI; t += 0.001) { // <- or different step
    double x = RadiusX * Math.Cos(t);
    double y = RadiusY * Math.Sin(t);

    Paint(x, y);
  }

这篇关于如何从点创建椭圆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆