Hjälp med Rasterization Hermite splines

Permalänk

Hjälp med Rasterization Hermite splines

Det är så att jag fastnat på en del frågor men ändå lyckats få koden korrekt.

såhär lyder instruktionerna:

Practical 1
Rasterization
Hermite splines

Problem 1: Rasterizer - DDA1

A simple method for rasterizing line segments (i.e. lines between two vertices
v0 and v1) is called DDA.
The idea of this algorithm can be described as follows:
Iterate over all the x-values (in screen coordinates!) between the x-coordinate
of v0 to the x-coordinate of v1.

In every step, the y-value has to be updated by adding the slope of the line to
y: y = y +slope. The coordinates of the next cell to 'll with a color' are x and
the rounded y-value

och dessa är då frågorna som jag inte lyckats svara på:

1. In the method, the slope of the line is used to calculate a new y-value:
a. What datatype is suitable for this variable if one should implement the
algorithm in Java?
b. Is the method for computing a new y-value (i.e. y = y + slope) correct?
Explain!
c. What datatype is suitable for storing the x-coordinate?

d.Is it possible to render arbitrary line segments
with this method, or do you see limitations? Explain!
In case you found limitations: Propose changes in the algorithm to make it
usable for at least one more case!
Hint: What happens if the line is vertical, i.e. x0 = x1?

Figure ;
Algorithm DDA:
Takes two vertices v0 och v1 as input.
slope = y
x
x = v0:x
y = v0:y
Do:
Raster[x][round(y)] = 1
x = x + 1
y = y + slope
While x < v1:x
End