2014-10-20 64 views
0

有誰知道,如果有一個使用PID過濾器反饋控制的Bresehham線算法的修改版本?基本上,算法只是一個P反饋控制,誤差項被放大一半。我看了看顯卡寶石系列,Abrash的書..等等找不到任何尚未Bresehham的線條繪製算法和PID

+0

你可以擴展一下這個「PID過濾器」是什麼或在哪裏可以找到更多的信息?標籤中的'pid'似乎與其描述無關。 – usr2564301 2014-10-20 15:34:50

+0

我對此表示懷疑。 Bresenham針對「受控實體」解決了一個非常具體的誤差最小化問題,並且具有微不足道,完全理解的響應動態。 PID控制器用於一般控制問題,其中受控實體對反應的理解程度很差。 – Gene 2014-10-20 16:22:10

+0

@Jongware實際上是一個錯字。 – 2014-10-20 18:27:38

回答

0

這就是:From Here。這使用P參數(請參閱鏈接頂部顯示的僞代碼中的步驟)

提供的示例代碼是在舊環境(代碼中引用TurboC)中編寫的,其中包含必須由您編寫的函數。例如。 initgraph()putpixel()等,但算法似乎是完整的。

#include <stdio.h> 
    #include <conio.h> 
    #include <graphics.h> 
    #include <math.h> 
    #include <dos.h> 

    int main() { 
     /* request auto detection */ 
     int gdriver = DETECT, gmode; 
     int x1 = 0, y1 = 0, x2, y2; 
     int err, x, y, dx, dy, dp, xEnd; 
     int twody, twodxdy; 

     /* initialize graphic driver */ 
     initgraph(&gdriver, &gmode, "C:/TURBOC3/BGI"); 
     err = graphresult(); 

     if (err != grOk) { 
       /* error occurred */ 
       printf("Graphics Error: %s\n", 
           grapherrormsg(err)); 
       return 0; 
     } 

     /* max position in x and y axis */ 
     x2 = getmaxx(); 
     y2 = getmaxy(); 

     /* draws line from (0, 0) to (x2, y2) */ 
     dx = x2 - x1; 
     dy = y2 - y1; 

     twody = 2 * dy; 
     twodxdy = 2 * (dy - dx); 

     dp = twody - dx; 

     if (x1 > x2) { 
       x = x2; 
       y = y2; 
       xEnd = x1; 
     } else { 
       x = x1; 
       y = y1; 
       xEnd = x2; 
     } 

     /* put a dot at the position (x, y) */ 
     putpixel(x, y, WHITE); 

     /* calculate x and y successor and plot the points */ 
     while (x < xEnd) { 
       x = x + 1; 
       if (dp < 0) { 
         dp = dp + twody; 
       } else { 
         y = y + 1; 
         dp = dp + twodxdy; 
       } 

       /* put a dot at the given position(x, y) */ 
       putpixel(x, y, WHITE); 

       /* sleep for 50 milliseconds */ 
       delay(50); 
     } 

     getch(); 

     /* deallocate memory allocated for graphic screen */ 
     closegraph(); 

     return 0; 
    } 
+0

儘管我不確定OP的「修改」算法是什麼,但它肯定只是*原始算法? – usr2564301 2014-10-20 21:41:44

+0

誰知道?如果你給我看一張審查過的原件,我會和這個人做一個差異並告訴你。 :) – ryyker 2014-10-20 22:26:37