COM366 - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

COM366

Description:

COM366. COM 366. Interactive Computer Graphics ... Plot(X,Y,props) ... Light(props) Creates all the properties of a light source to view a scene. Camlookat ... – PowerPoint PPT presentation

Number of Views:12
Avg rating:3.0/5.0
Slides: 17
Provided by: ericfl
Category:
Tags: com366 | props

less

Transcript and Presenter's Notes

Title: COM366


1
COM 366 Interactive Computer Graphics Topic 1
Introduction
COM366
2
A simple data structure
COM366
3
Drawing a line in Matlab
(3,4)
X -1 3
Y -2 4
(-1,-2)
plot(X,Y)
COM366
4
Drawing a line with MATLAB
function LineDemo To draw a single line First
of all define the two node vectors X -1 3 Y
-2 4 Draw the line plot(X,Y) Set the
limits to the axes and ensure they are of equal
dimension axis(-5,5,-5,5) axis square
COM366
5
The line drawn
COM366
6
Changing the appearance of the line
plot(X,Y,'Color','red','LineWidth',2)
Column vectors for drawing the square
X Y
-2 -2
-2 2
2 2
2 -2
-2 -2
COM366
7
Combining the X and Y arrays
Column 1
(-2,-2) ? (-2,2) (-2,2) ? (2,2) (2,2) ?
(2,-2) (2,-2) ? (-2,-2)
-2, -2 -2, -2 2, 2 2, -2 -2, -2
(2,-2)
(-2,-2)
Row 3
Node -2 -2 -2 2 2 2 2 -2-2 -2
COM366
8
A useful Matlab convention
Node -2 -2 -2 2 2 2 2 -2-2 -2
Node(,1)
Means take ALL rows from column 1 of array node
Node(3,)
Means take ALL columns from row 3 of array node
Node(1..3,1)
Means take rows 1 to 3 from column 1 of array
node
COM366
9
Drawing the square
function Drawsquare To draw a square using
nodes First of all define the nodes Node -2
-2 -2 2 2 2 2 -2-2 -2 Draw the
square plot(Node(,1),Node(,2)) axis(-5,5,-5,5)
axis square
COM366
10
Alternative ways of drawing the square
Using patch
Using fill
function Drawsquare2 To draw a square using
patch First of all define the nodes Node -2
-2 -2 2 2 2 2 -2 Draw the
square patch(Node(,1),Node(,2),'red') axis(-5,5
,-5,5) axis square
fill(Node(,1),Node(,2),C)
COM366
11
Drawing in three dimensions
patch(x-coordinates,y-coordinates,z-coordinates,
colordata)
COM366
12
The viewing pipeline
COM366
13
COM366
14
Degrees and radians
Most computer languages (including Matlab) like
to use angles in Radians in their trigonometric
functions like sine and cosine
  • We normally like to think in degrees. Fortunately
    the conversion is
  • easy if you remember that
  • Radians is equivalent to 180o
  • So for example 45o is 45 pi/180 radians

COM366
15
Adding a circle primitive
function Circle(R) Draws a circle centred on
the origin of radius R t 0pi/362pi x
Rsin(t) y Rcos(t) fill(x,y,'w') axis square
pi is the Matlab convention for ? 3.1416..
COM366
16
COM366
Write a Comment
User Comments (0)
About PowerShow.com