Professional Documents
Culture Documents
Mumba Individual Algos
Mumba Individual Algos
Mumba Individual Algos
INDIVIDUAL ASSIGNMENT 2
NAME: CHARITY MUMBA
It is based on the function for testing the spatial relationship between the arbitrary point
(x, y) and a circle of radius r centered at the origin:
Input the radius r and the circle center (xc,yc)r to get the initial point on the circumference of
a circle centered on the origin: (x0, y0) = (0, r).
Step2: Repeat steps while x ≤ y. Plot (x, y) If (p<0) Then set p = p + 2x + 3. Else. p = p + 2(x-y)
+5. y =y - 1 (end if) x =x+1 (end loop)
Now, consider the coordinates of the point halfway between pixel T and pixel S. This is
If Pi ispositive then midpoint is outside the circle (or on the circle)and we choose pixel S.
Step5: We can continue to simplify this in n terms of (xi,yi) until getting the initial value of Pi
(0,r)from equation 2 where r is an integer
Step 6: Output
Thus P1=1-r
Thus in brief the steps are written as follows and there can be many equations until the
initial value of P becomes an integer.
Step3: End
The initial point for the circle centered on the coordinate origin is (x0, y0) - (0, 10), and the first
increment terms for calculating the choice parameters are: 2x0 = 0, 2y0 = 20.
The midpoint approach is used to calculate successive decision parameter values and positions
along the circle path as follows:
K Pk (Xk+1, Yk+1) 2Xk+1 2Yk+1
0 -9 (1,10) 2 20
1 -6 (2,10) 4 20
2 -1 (3,10) 6 20
3 6 (4,9) 8 18
4 -3 (5,9) 10 18
5 8 (6,8) 12 16
6 5 (7,7) 14 14
This transformation entails creating formulas that begin with a point in the world window, such
as (x, y)
where the viewing coordinate limitations are determined by the parameters xwmin, xwmax,
ywmin, and ywmax, while the viewport limits are determined by the normalised coordinate
positions xvmin, xvmax, yvmin, and yvmax.
ii) Write a function to store combinations of viewing and window-viewpoint mapping for
various workstations (5)
To save viewing and window-viewport mapping combinations for different workstations, we use
the following function:
setViewRepresentation
(ws, viewIndex, viewMatrix, viewMappingMatrix,
xclipmin, xclipmax, yclipmin, yclipmax, clipxy)
Where argument ws represent the workstation's output device and parameter viewIndex specifies
image identification for this specific window-viewport pair.
The maximum size of a workstation window is (0.0,1.0)x (0.0,1.0). The maximum workstation
viewport is the workstation's entire display surface. There is a simple approach to ensure that an
application uses the entire workstation display surface, regardless of the type of output device it
is using. The function Inquire display space size (GQDSP) returns the maximum x and y ranges
for DC units, among other things. The largest of these should be chosen, and the aspect ratio of
the NDC workstation window is selected to be the same as the aspect ratio of the display surface.
The graphics image will then be mapped to the entire display surface via the workstation
transformation. This can be illustrated as follows:
Comment: This approach can be used to make use of the complete display surface in an
application.