Saturday, August 10, 2019

Overview of Transformation PPT



Overview of Transformation

Transformation

Transformation changes the way object appears.
Implementing changes in size of object, its position on screen or its orientation called Transformation.

Basic 2D Transformation

Translation
Scaling
Rotation

Translation

Translation is a process of changing the position of an object in a straight line path from one coordinate location to another.

A translation moves all points in an object along the same straight-line path to new positions.

The path is represented by a vector, called the translation or shift vector.
Rotation

Rotation transformation re-position an object along a circular path in the xy plane.
The rotation is performed with certain angle θ, known as rotation angle
A rotation re-positions all points in an object along a circular path in the plane centered at the pivot point.

Reflection

Produces a mirror image of an object relative to an axis of reflection.

Shear

A transformation that slants the shape of an object is called the shear transformation

X Shear

                preserves y coordinates but changes x values

Y Shear

                preserves x coordinates but changes y values   

3D Coordinate Systems

3 D Translation

In translation, an object is displaced and direction from its original position.
The new object point p’=(x’,z’,z’) can be found by applying the transform Ttx,ty,tz to p=(x,y,z)
Here tx=distance moved by object along x-axis
         ty=distance moved by object along y-axis
         tz=distance moved by object along z-axis

3D Translation

P is translated to P' by:

An Object represented as a set of polygon surfaces, is translated by translate each vertex  of each surface and redraw the polygon facets in the new position.

3D Rotation

Coordinate Axis Rotations
Coordinate Axis RotationsRotation About Z-axis In

Clockwise direction.
Note that the +ve values of rotation angle Ө will produce a rotation in the anticlockwise direction whereas –ve values of  Ө     produce a rotation in the clockwise direction.
in this case angle Ө   is taken as –ve. According to the trigonometric law
                     cos(Ө)= cos Ө
                       sin(- Ө)= -sin Ө

Scaling Transformation

A scaling transformation alters the size of an object.
An object can be scaled (stretched or shrunk) along the x, y and z axis by multiplying all its points by the scale factors Sx, Sy, Sz

All points P(x, y, z) on the scaled shape will now become P’(x’, y’, z’). Such that
                  x’=x.Sx
                  y’=y,Sy
                  z’=z.Sz

3D Scaling

Scaling Transformation

If values of Sx, Sy and Sz<1 then size of objects reduced or the object move closer to the coordinate origin.

If values of Sx, Sy and Sz>1 then size of objects increased or the object move farther to the coordinate origin.

2 types of projections


Parallel
In parallel projection, coordinate positions are transformed to the view plane along parallel lines.

Perspective
In perspective projection, object position are transformed to the view plane along lines that come together to a point called projection reference point

Parallel Projection

Z coordinate is discarded.
Parallel lines from each vertex on the object are extended until they intersect the view plane.
The point of intersection is the projection of vertex.
Projected vertices are connected by line segments to correspond connection on original object.

Perspective Projection

Produces realistic views but does not preserves relative proportions.
Lines of projection are not parallel.
Instead they all converge at single point called projection reference point.


You can also download the same PPT from slideshare following link



Monday, August 5, 2019

IPv6 Multicast Addresses

Important IPv6 multicast addresses in CCNA exam perspective


FF01::1    -    ALL NODES(NODE-LOCAL)
FF01::2    -    ALL ROUTERS (NODE-LOCAL)
FF02::1    -    ALL NODES (LINK-LOCAL)
FF02::2    -    ALL ROUTERS (LINK LOCAL)
FF02::5    -    OSPFv3 ROUTERS
FF02::6    -    OSPFv3 DESIGNATED ROUTERS
FF02::9    -     RIPng
FF02::A    -    EIGRP ROUTERS
FF02::B    -    MOBILE AGENTS
FF02::C    -    SSDP
FF02::D    -    ALL PIM ROUTERS
FF05::2     -   ALL ROUTERS (SITE LOCAL)
FF05::1:3  -   DHCP SERVERS/RELAY AGENTS

Tuesday, October 9, 2018

c program for Sutherland Hodgemen Polygon clipping

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
#include<dos.h>
void dda(int,int,int,int,int,int,int,int);
void dda(int x1,int y1,int x2,int y2,int xmin,int ymin,int xmax,int ymax)
{
float dx,dy;
float steps,x=x1,y=y1;
int i=0;
dx=x2-x1;
dy=y2-y1;
if(abs(dx)>=abs(dy))
steps=abs(dx);
else
steps=abs(dy);
dx=dx/steps;
dy=dy/steps;
while(i++<=steps)
{
if(x>=xmin && x<=xmax && y>=ymin && y<=ymax)
{
line(x,y,x2,y2);
getch();
return;
}
x=x+dx;
y=y+dy;
}
}

void main()
{
int n,gd,gm,x1,x2,y1,y2,xRec,yRec,b1,b2,b3,b4,l,b,yMin,yMax,xMin,xMax;
float m;
int a[10][4],i,j, flag=0,in=0;
gd=DETECT;
initgraph(&gd,&gm,"C:\\TC\\BGI");
printf("Enter the length and breadth of the clipping window:\n");
scanf("%d%d",&l,&b);
printf("Enter the starting co-ord of the rectangle\n");
scanf("%d%d",&xRec,&yRec);
cleardevice();
rectangle(xRec,yRec,xRec+l,yRec+b);
getch();
cleardevice();
printf("Enter the no of lines\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter the co-ord of line %d\n",i+1);
for(j=0;j<2;j++)
{
scanf("%d",&a[i][j]);
}
a[i][2]=a[0][0];
a[i][3]=a[0][1];
if(i!=0)
{
a[i-1][2]=a[i][0];
a[i-1][3]=a[i][1];
}
}
cleardevice();
rectangle(xRec,yRec,xRec+l,yRec+b);
for(i=0;i<n;i++)
{
line(a[i][0],a[i][1],a[i][2],a[i][3]);
}
getch();
cleardevice();
rectangle(xRec,yRec,xRec+l,yRec+b);
xMin=xRec;
yMin=yRec;
xMax=xRec+l;
yMax=yRec+b;
for(i=0;i<n;i++)
{
flag=0;
x1=a[i][0];
x2=a[i][2];
y1=a[i][1];
y2=a[i][3];
if(x1>=xMin && x1<=xMax && y1>=yMin && y1<=yMax)
flag++;
if(x2>=xMin && x2<=xMax && y2>=yMin && y2<=yMax)
flag++;
switch(flag)
{
case 0: break;
case 1:
if(x2>=xMin && x2<=xMax && y2>=yMin && y2<=yMax)
{
dda(x1,y1,x2,y2,xMin,yMin,xMax,yMax);
}
else
{
dda(x2,y2,x1,y1,xMin,yMin,xMax,yMax);
}
break;
case 2:
line(x1,y1,x2,y2);
break;
}
}
getch();
closegraph();
}

c program for Hilbert's Curve computer graphics

#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <graphics.h>
#include <conio.h>

void move(int j, int h, int &x, int &y)
{
if(j==1)
y-=h;
else if(j==2)
x+=h;
else if(j==3)
y+=h;
else if(j==4)
x-=h;
lineto(x,y);
delay(10);
}

void hilbert(int r,int d,int l,int u,int i,int h,int &x,int &y)
{
if(i>0)
{
i--;
hilbert(d,r,u,l,i,h,x,y);
move(r,h,x,y);
hilbert(r,d,l,u,i,h,x,y);
move(d,h,x,y);
hilbert(r,d,l,u,i,h,x,y);
move(l,h,x,y);
hilbert(u,l,d,r,i,h,x,y);
}
}

void main()
{
int n,x1,y1;
int x0=50,y0=150,x,y,h=10,r=2,d=3,l=4,u=1;
printf("\nGive the value of n: ");
scanf("%d",&n);
x=x0;y=y0;
int gm,gd=DETECT;
initgraph(&gd,&gm,NULL);
moveto(x,y);
hilbert(r,d,l,u,n,h,x,y);
getch();
closegraph();
}

C program for Koch curve Computer graphics

#include<graphics.h>
#include<conio.h>
#include<math.h>

void koch(int x1, int y1, int x2, int y2, int it)
{
 float angle = 60*M_PI/180;
 int x3 = (2*x1+x2)/3;
 int y3 = (2*y1+y2)/3;

 int x4 = (x1+2*x2)/3;
 int y4 = (y1+2*y2)/3;

 int x = x3 + (x4-x3)*cos(angle)+(y4-y3)*sin(angle);
 int y = y3 - (x4-x3)*sin(angle)+(y4-y3)*cos(angle);

 if(it > 0)
 {
  koch(x1, y1, x3, y3, it-1);
  koch(x3, y3, x, y, it-1);
  koch(x, y, x4, y4, it-1);
  koch(x4, y4, x2, y2, it-1);
 }
 else
 {

  line(x1, y1, x3, y3);
  line(x3, y3, x, y);
  line(x, y, x4, y4);
  line(x4, y4, x2, y2);
 }
}

int main(void)
{
 int gd = DETECT, gm,i,n, x1 = 100, y1 = 100, x2 = 400, y2 = 400;
 initgraph(&gd,&gm,"");
 printf("Enter number of interations");
 scanf("%d",&n);
 for(i=0;i<n;i++)
 {
 cleardevice();
 koch(x1, y1, x2, y2, i);
 getch();
 }
 return 0;
}