In: Computer Science
Interactive computer graphics course.
by java language, no need to explain.
Q1: Draw a line between P0 and Pe
P0= (x,y)=(2,5)
Pe=(xe,ye)=(7,9)
Q2: P=(3,5) Scale P by (5,7) and then sheer by -3 along y-axis
Ans a) P0=(x,y)=(2,5)
Pe=(xe,ye)=(7,9)
Parametric equation of line is y=mx+b
where m=(ye-ys)/(xe-xs)
m=(9-5)/(7-2)=4/5=0.8
m<1 indicates that line is closer to x
then xi+1=xi+1
and yi+1=yi+m at each step of DDA algorithm
x | y | plotted y |
2 | 5 | 2,5 |
2+1=3 | 5+0.8=5.8 | 3,6 |
3+1=4 | 5.8+0.8=6.6 | 4,7 |
4+1=5 | 6.6+0.8=7.4 | 5,7 |
5+1=6 | 7.4+0.8=8.2 | 6,8 |
6+1=7 | 8.2+0.8=9.0 | 7,9 |
now we have reached the point 7,9 so we will stop here and according to the plotted pts line can be drawn(we always use integer value for plotting a line in dda algorithm so pt y is rounded off for plotting).
Ans 2)P(x,y)=3,5
scaling factor Sx=5 and Sy=7 are given
After scaling
P(x')=Sx.x=5*3=15
P(y')=sy.y=7*5=35
So after scaling the point will be P(15,35)
Now On shearing this pt by -3 along y axis
means
now we have x=15,y=35
formula for shearing along y axis is
y'=y+shy.x and x'=x
where shy is shearing value along y axis
which is given as -3
now using the formula we get
x'=x=15
y'=35+15*(-3)=35-45=-10
So after shearing new coordinates will be 15,-10
So answer will be P(15,-10)