联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> Java编程Java编程

日期:2021-03-24 10:36

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.


版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp