1. Trang chủ
  2. » Công Nghệ Thông Tin

Lecture Computer graphics: Lecture 26 - Fasih ur Rehman

12 77 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 12
Dung lượng 24,44 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

In this chapter, you learn what is input and output devices. The keyboard is presented and different keyboard types are described. You are introduced to various pointing devices, such as the mouse, trackball, touchpad, pointing stick, joystick, touchscreen, and pen input. Scanners and reading devices, including optical scanners, optical readers, magnetic ink character recognition readers, and data collection devices are explained,...

Trang 1

Computer Graphics

Lecture 26 Fasih ur Rehman

Trang 2

Last Class

Trang 3

Today’s Agenda

Trang 4

Matrix Multiplication

void matrixMul(float P[1][3],float T[3][3])

{

int i,j,k; //Initialize Matrix P1 with Zero

for(i=0;i<3;i++)

P1[0][i]=0; /*Mutiply T with P and store the result in P1 */

for(k=0;k<1;k++)

for(i=0;i<3;i++)

[i]+=P[k][j]*T[j][i];

}

Trang 5

Matrix Identity

void matrixIdentity(float T[3][3])

{

int i,j;

/* Make matrix T as Identity Matrix by Storing 1 in the left diagonal positions of Matrix T and store 0 in other positions */

for(i=0;i<3;i++) {

for(j=0;j<3;j++) {

if(i==j)

T[i][j]=1;

else

T[i][j]=0;

} }

}

Trang 6

void translate_point(int x,int y,int tx,int ty)

//Translate a point by translation factors tx,ty {

float T[3][3];

matrixIdentity(T);

T[2][0]=tx;

T[2][1]=ty;

P[0][0]=x;

P[0][1]=y;

P[0][2]=1;

matrixMul(P,T);

}

Trang 7

void rotate_point(int x,int y,float angle) // Rotate a point by given angle

{

float R[3][3];

float radian;

radian=(3.141/180)*angle;

matrixIdentity(R);

R[0][0]=cos(radian);

R[1][0]=-1*sin(radian);

R[2][0]=0;

R[0][1]=sin(radian);

R[1][1]=cos(radian);

R[2][1]=0;

P[0][0]=x;

P[0][1]=y;

P[0][2]=1;

matrixMul(P,R);

}

Trang 8

void scale_point(int x,int y,float sx,float sy)

/* Scale a point by scaling factors sx,sy and with respect to some fixed point */

{

float S[3][3];

matrixIdentity(S);

S[0][0]=sx;

S[2][0]=0;

S[1][1]=sy;

S[2][1]=0;

P[0][0]=x;

P[0][1]=y;

P[0][2]=1;

matrixMul(P,S);

}

Trang 9

void reflect_point_X(int x,int y) {

float R[3][3];

matrixIdentity(R);

R[1][1]=-1;

P[0][0]=x;

P[0][1]=y;

P[0][2]=1;

matrixMul(P,R);

}

Trang 10

void shear_point_Y(int x,int y,float shy) {

float R[3][3];

matrixIdentity(R);

R[0][1]=shy;

P[0][0]=x;

P[0][1]=y;

P[0][2]=1;

matrixMul(P,R);

}

Trang 11

Summary

Trang 12

Edition by Peter Shirley and Steve

Marschner

Top-down Approach with OpenGL (Sixth

Edition) by Edward Angel

rame_cpp.html

Ngày đăng: 30/01/2020, 07:49