1 / 10

Plotting a Line

Plotting a Line. Discussion 11.5 Rev B 3/30/2006. plot(x,y,color). Example of the need for a stack. int orig_x, orig_y, endp_x, endp_y, midp_x, midp_y; if (orig_x > endp_x) then exchange orig and endp; push endp; push endp while (stack is not empty) // compute midp

glynn
Download Presentation

Plotting a Line

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Plotting a Line Discussion 11.5 Rev B 3/30/2006

  2. plot(x,y,color) Example of the need for a stack

  3. int orig_x, orig_y, endp_x, endp_y, midp_x, midp_y; if(orig_x > endp_x) then exchange orig and endp; push endp; push endp while(stack is not empty) // compute midp midp_x = (orig_x + endp_x)/2; if(endp_y < orig_y) then midp_y = (orig_y + endp_y)/2 (rounded); else midp_y = (orig_y + endp_y)/2; if(midp = orig) then plot orig; pop orig; pop endp; else push endp; push midp; endp = midp; end while;

  4. Datapath

  5. int orig_x, orig_y, endp_x, endp_y, midp_x, midp_y; if(orig_x > endp_x) then exchange orig and endp; push endp; push endp while(stack is not empty) // compute midp midp_x = (orig_x + endp_x)/2; if(endp_y < orig_y) then midp_y = (orig_y + endp_y)/2 (rounded); else midp_y = (orig_y + endp_y)/2; if(midp = orig) then plot orig; pop orig; pop endp; else push endp; push midp; endp = midp; end while; Datapath

  6. >: if orig_x > orig_y then xgtflg <= ‘1’ ; else xgtflg <= ‘0’ ; end if; =: if (orig_x = midp_x) and (orig_y = midp_y) then eqflg <= ‘1’ ; else eqflg <= ‘0’ ; end if;

  7. +/2: tempx <= (orig_x + endp_x); xmid <= ‘0’ & tempx(10 downto 1); +/2C: tempy <= (orig_y + endp_y); if(yltflg = '1') then ymid <= (‘0’ & tempy(10 downto 1)) + (“0000000000” & tempy(0)); else ymid <= ‘0’ & tempy(10 downto 1);

  8. State Diagram

  9. int orig_x, orig_y, endp_x, endp_y, midp_x, midp_y; if(orig_x > endp_x) then exchange orig and endp; push endp; push endp while(stack is not empty) // compute midp midp_x = (orig_x + endp_x)/2; if(endp_y < orig_y) then midp_y = (orig_y + endp_y)/2 (rounded); else midp_y = (orig_y + endp_y)/2; if(midp = orig) then plot orig; pop orig; pop endp; else push endp; push midp; endp = midp; end while;

More Related