91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

DDA直線插補matalb實現,帶左移規格化處理,插補效果更好,更加便于速度規劃。

資源截圖

代碼片段和文件信息

%DDA數字積分法插補:
%(xsys)起點坐標
%(xeye)起點坐標
%buffBitWidth?寄存器位寬
%base?基準:1全加載?2半加載?其他?普通
function?DDA_Line2()%(xsys?xeye?buffBitWidth?base)
????%clc
????close?all
????clear?all
????
????global?x?y?speed;
????%global?x?y?m?speed?steplengh?base?zuo;
????%初始化參數------------------------------
????speed=0.01;?%speed?of?running插補速度.
????xs?=0;??%?x?start?point?x起始點
????ys?=0;??%?y?start?point?y起始點
????xe?=1005;?%?x?end?point?x終點
????ye?=1003;?%?y?end?point?y終點
????buffBitWidth=16;%寄存器位數
????zuo=1;%左移偏置開關?1?開?0?關
????base=1;%是否全加載1全加載?2半加載?其他?普通
????steplengh=1;%步長設置
????%理論曲線繪制-----------------------------
????grid?on;
????plot([xsxe][ysye]‘r-‘);hold?on;
????title(‘DDA直線插補圖像‘);
????xlabel(‘x‘);
????ylabel(‘y‘);

????%?main?part--------------------------------------------
????if?(xe-xs)>0
????????xdir?=?1;
????else
????????xdir?=?-1;
????end
????if?(ye-ys)>0
????????ydir?=?1;
????else
????????ydir?=?-1;
????end
????jx0?=?abs(xe-xs);
????jy0?=?abs(ye-ys);
????if(zuo)%進行左移規格化操作
????????while(jx0&&jy0<=(0.5*2^buffBitWidth))
????????????jx0=2*jx0;
????????????jy0=2*jy0;
????????end

????end
????switch?base
????????case?1?
????????????jx=2^buffBitWidth;
????????????jy=2^buffBitWidth;
????????case?2?
????????????jx=0.5*2^buffBitWidth;
????????????jy=0.5*2^buffBitWidth;
????????otherwise?
????????????jx=0;
????????????jy=0;
????end
????x=xs;
????y=ys;
????xplus?=?abs(xe-xs);
????yplus?=?abs(ye-ys);
????output(xsys);?%?move?to?start?point.
????while(xplus>0?||?yplus>0)
????????jx=jx0+jx;
????????jy=jy0+jy;
???????if?jx?>?2^buffBitWidth&&jy>2^buffBitWidth
???????????xstep?=?redo(xplus?steplengh);
???????????ystep?=?redo(yplus?steplengh);
????????????output(xdir*xstep?ydir*ystep);
????????????x?=?x+xdir*xstep;?
????????????y?=?y+ydir*ystep;?
????????????xplus=xplus-xstep;
????????????yplus=yplus-ystep;
????????????jx=jx-2^buffBitWidth;
????????????jy=jy-2^buffBitWidth;
???????end
???????if?jx>2^buffBitWidth&&jy<2^buffBitWidth
???????????xstep?=?redo(xplus?steplengh);
????????????output(xdir*xstep?0);
????????????x?=?x+xdir*xstep;??
????????????xplus=xplus-xstep;
????????????jx=jx-2^buffBitWidth;
???????end
???????if?jx<2^buffBitWidth&&jy>2^buffBitWidth
???????????ystep?=?redo(yplus?steplengh);
????????????output(0?ydir*ystep);
????????????y?=?y+ydir*ystep;?
????????????yplus=yplus-ystep;
????????????jy=jy-2^buffBitWidth;
???????end
????end???????
end

function??output(dxdy)
????global?x?y?speed;
????xi=x;??
????yi=y;
????xj=x+dx;?
????yj=y+dy;
????%if(dx)
????%????dx=dx
????%????disp(‘output‘)
????%end
????plot([xixj][yiyj]‘b-‘);hold?on;
????pause(speed);
end

function??step?=?redo(data?n)
????if(data>0)?
???????step=n;
????else
???????step=0;
????end
end

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????2925??2018-11-06?20:45??DDA_Line2.m

-----------?---------??----------?-----??----

?????????????????2925????????????????????1


評論

共有 條評論