Professional Documents
Culture Documents
x0,y0,z0) be
defined in terms of scaling with respect to the origin?
Scaling
along all directions or scaled down along the X axis only. To scale, we usually
apply the scaling matrix below:
a 0 0 0
0 b 0 0
0 0 c 0
0 0 0 1
Where p, q, and r are the scaling factor along the X, Y, and Z direction,
respectively. The figure below shows the effect of scaling |
V=ai+bJ+cK=I+J+K
|V|= a + b +c
2 2 2
= 1 +1 +1 = 3
2 2 2
= b +c = 1 +1 = 2
2 2 2 2
2 0 1 0
3 3
1 1 1
0
Av = 2 3 3 3
1 1 1
0
2 3 2 3
0001
3.Find the transformation which aligns vector
V=I+J+K with the vector N=2I-J-K.
Ans : A v.N=
A . N 1 .
AV
Finding AV
Here |V|= 3
= 2 a=1,b=1,c=1
Then
2 0 1 0
3 3
1 1 1
0
Av = 2 3 3 3
1 1 1
0
2 3 2 3
0001
according to Q.
1
A .N
GIVEN
N=2I-J-K.
22+12 +12 = 6
= 2 ,a=2,b=1,c=1
2 2 2 0
6 2 6 6
1 1
A1 v 0 0
= 2 6
2 1 1
0
6 2 6
0001
2 I J K
2 2
V= A V=
v.N.
A1
v Av .v = 2 6
THEN
2 N
V= 2
PART B
Note the difference between this strategy for a polygon and the Cohen-Sutherland
algorithm for clipping a line: The polygon clipper clips against four edges in
succession, whereas the line clipper tests the outcode to see which edge is crossed,
and clips only when necessary.
The clip boundary determines a visible and invisible region. The edges from
vertex i to vertex i+1 can be one of four types:
procedure SutherlandHodgmanPolygoClip (
inVertexArray : vertexArray; /*Input vertex array*/
var outVertexArray : vertexArray; /*Output vertex array*/
inLength : integer; /*Number of entries in inVertexArray*/
var outLength : integer; /*Number of entries in outVertexArray*/
clipBoundary : edge); /*Edge of clip polygon*/
var
s,p, /*Start, end point of current polygon edge*/
i : vertex; /*Intersection point with a clip boundary*/
j : integer; /*Vertex loop counter*/
procedure Output(
newVertex : vertex; var outLength : integer; var outVertexArray :
vertexArray);
/*Adds newVertex to outVertexArray and then updates outLength */
begin
...
end;
begin
outLength := 0;
s := inVertexArray[inLength];
/*Start with the last vertex in inVertexArray*/
for j := 1 to inLength do
begin
p := inVertexArray[j]; /*Now s and p correspond to the vertices in Fig.
3.48*/
if Inside(p,clipBoundary) then /*Cases 1 and 4*/
if Inside(s, clipBoundary) then
Output(p, outLength, outVertexArray) /*Case 1*/
else
begin
Intersect(s, p, clipBoundary, i);
Output(i, outLength, outVertexArray);
Output(p, outLength, outVertexArray)
end
else /*Cases 2 and 3*/
if Inside(s, clipBoundary) then /*Cases 2*/
begin
Intersect(s, p, clipBoundary, i);
Output(i, outLength, outVertexArray)
end; /*No action for case 3*/
s := p /*Advance to next pair of vertices*/
end /*for*/
end; /*SutherlandHodgmanPolygonClip*/
(A)
(b)
Now our line will be P1C
OUTCODE (P1)=0000
OUTCODE (C)=0000
Result of logical AND is 0000
m=(100-70)/(10-20)= -3
Y=y1+m*(x-x1);
Y=20+(-3)*(80-70)
Y=20-30=-10
Xnew =(50+(-10)/2=20;
Ynew=(10+20)/2=15;
Now P1(20,15)
MID between P1 & Q
Xn= (50+20)/2=35
Yn =10+15)=12
So The Visible portion of line segment P& Q is from (0, 17) to(40, 11).
**********************Thanks**********************