首页 > > 详细

COMP4033编程辅导、Java语言程序调试、Java编程辅导辅导Web开发|调试Matlab程序

COMP4033 Project 1 – Algorithms for Drawing 2D Primitives (10%)
Due: 11:59pm, 27 March 2021
Complete the following two exercises by writing a Java program for each:
1. Replace the drawLine method based on Bresenham’s algorithm and listed almost at the end of Section
4.1 with an even faster version that benefits from the symmetry of the two halves of the line. For
example, with endpoints P and Q satisfying Equation (4.1), and using the integer value xMid halfway
between xP and xQ, we can let the variable x run from xP to xMid and also use a variable x2, which at
the same time runs backward from xQ to xMid. In each iteration of the loop, x is increased by 1 and x2
is decreased by 1. Note that there will be either one point or two points in the middle of the line,
depending on the number of pixels to be plotted being odd or even. Be sure that no pixel of the line is
omitted and that no pixel is put twice on the screen. To test the latter, you can use XOR mode so that
writing the same pixel twice would have the same effect as omitting a pixel.
2. Extend the program in Q1 to handle lines at any angle, call it "FasterBres", and take two endpoints
from the mouse input. The purpose of this part is to compare the speed of FasterBres and the standard
Bresenham algorithm. So you add the standard Bresenham algorithm into your program such that both
your FasterBres and the standard one will draw the same line. Make sure each line is drawn by the two
algorithms as two identical lines (so you may be unable to distinguish on the screen). Your program
should finally display the total counts for both algorithms in such a form: "FasterBres: N cycles;
Bresenham: M cycles.", where N and M are the total counts for the corresponding algorithms.
Q1 and Q2 could be in a single program, in that case, you should state clearly as comments on top of
your program which parts have been accomplished and which parts do not work. Ideally, you should
also explain how your program is implemented as comments on top of your program.
Put the 2 Java source programs in a ZIP file and name it as “Ass2_1234567890" (replace
1234567890 with your student ID number). Submit your ZIP file through iSpace before the due
time. Late submissions will NOT be accepted.

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!