Advertisement

角度离散法用于画弧与椭圆

阅读量:

角度离散法 能够借助现有的直线绘制技术,对圆弧与椭圆弧进行分段式描绘。其优势体现在可对所生成弧线的角度区间进行灵活调控。

在这里插入图片描述

完整代码实现:

复制代码
    #include<GL/glut.h>
    #include<windows.h>
    #include<math.h>
    void Arcellipse(int xc, int yc, double r, double ts, double te)
    {
     double pi = 3.1415926;
     if (te < ts)  //当终止角比起始角还小时,则将终止角加上2π
      te += 2 * pi;
     double dt = 0.4 / r; //取角度离散值,使其与半径r成反比
     int n = (int)((te - ts) / dt + 0.5); //确定总步数
     double ta = ts;
     int x = xc + int(r*cos(ts));
     int y = yc + int(r*sin

全部评论 (0)

还没有任何评论哟~