1 sung-ju kang department of physics kangwon national university basic concept of the computer...

6
1 Sung-Ju Kang Department of Physics Kangwon National Unive rsity Basic Concept of The Computer Graphic. For the investigation of the physical problem by using the computer, the visualization of the solution are very advantageous for the researcher. The computer graphic is different to the real graphic, below text is the basic concept of the computer graphic. Contents 1. Graphic Card and Graphic Mode. 2. The Real Coordinate to The Computer Coordinate. 3. The Real Floating Point to The Pixel Integer Point. 4. Basic Graphic Functions.

Upload: angelina-stone

Post on 14-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 Sung-Ju Kang Department of Physics Kangwon National University Basic Concept of The Computer Graphic. For the investigation of the physical problem by

1

Sung-Ju Kang

Department of Physics

Kangwon National University

Basic Concept of The Computer Graphic.

For the investigation of the physical problem by using the computer, the visualization of the solution are very advantageous for the researcher.

The computer graphic is different to the real graphic, below text is the basic concept of the computer graphic.

Contents

1. Graphic Card and Graphic Mode.

2. The Real Coordinate to The Computer Coordinate.

3. The Real Floating Point to The Pixel Integer Point.

4. Basic Graphic Functions.

Page 2: 1 Sung-Ju Kang Department of Physics Kangwon National University Basic Concept of The Computer Graphic. For the investigation of the physical problem by

2

1. Graphic Card and Graphic Mode.

graphic card Graphic driver

HGA herc.bgi

EGA ega.bgi

VGA egavga.bgi

C language support the BGI (Borland Graphics Interface).

Graphic driver of graphic card must exist in folder.

Page 3: 1 Sung-Ju Kang Department of Physics Kangwon National University Basic Concept of The Computer Graphic. For the investigation of the physical problem by

3

2. The Real Coordinate to The Computer Coordinate.

The computer recognize the left upper edge as the origin, output images must be represented through the rectangular coordinate

• Real Coordinate:

• Windows Coordinate: )VU,(

),( yx

);12()12/()2(V

);12()12/()1(U

vyvywywyywy

vxvxwxwxwxx

.

.

.

.

.

)0,0(

480

)479,639(

V)(U,y)(x,

)11( ,wywx

)11( ,vyvx

)22( ,vyvx

)2,2( wywx

X

Y

640

.

Page 4: 1 Sung-Ju Kang Department of Physics Kangwon National University Basic Concept of The Computer Graphic. For the investigation of the physical problem by

4

3. The Real Floating Point to The Pixel Integer Point.

• Unit in the real world: Floating point number

• Unit in the computer graphic: Integer number

transform

int round(double U)

{

return(( U>0 ) ? (int) floor(U + 0.5) : (int) ceil(U - 0.5));

}

floor find the largest integer not > U

ceil find the smallest integer not < U

ex) U = 123.54

floor(U) = 123.00

ceil(U) = 124.00

),( yx

)VU,(

Page 5: 1 Sung-Ju Kang Department of Physics Kangwon National University Basic Concept of The Computer Graphic. For the investigation of the physical problem by

5

4. Basic Graphic Functions.

• Plot a point in the screen

* putpixel(x,y,color) putpixel plots a pixel at a specified point.

• Plot to print a character String in the screen

* outtextxy(x,y,s) outtextxy displays a string at the specified location.

(graphics mode)

• Plot a line in the screen

* line(x1,y1,x2,y2) line draws a line between two specified points.

Page 6: 1 Sung-Ju Kang Department of Physics Kangwon National University Basic Concept of The Computer Graphic. For the investigation of the physical problem by

6

Summary

1. C language support the BGI (Borland Graphics Interface).

2. We study the computer coordinate and the unit in the computer graphic.

3. We study the handling a point and a line in the screen.