COM 366 Reading Data. COM 366 Reading data from disc files Organise the data in a logical fashion with comments as necessary. #Data for a cube # First.

Slides:



Advertisements
Similar presentations
Points, Lines, and Shapes!
Advertisements

Three-Dimensional Figures. Vocabulary Two-dimensional figures (plane figures) – triangles, quadrilaterals, and circles. They lie in one plane.
Characteristics of 3-D Shapes
Solid Geometry.
Bell Ringer Get out your notebook and prepare to take notes on Chapter 8 What is the difference between two-dimensional and three-dimensional?
1 Computer Graphics Chapter 7 3D Object Modeling.
Hidden Line Removal Adopted from U Strathclyde’s course page.
Chapter 4 Digital Multimedia, 2nd edition Vector Graphics.
ENGINEERING GRAPHICS 1E9
Transformations, Constructions and 3D Drawings
PRESENTATION on AutoCAD 2013 Submitted By :- Dev RANA MECHANICAL BRANCH.
2D and 3D Shapes. What is a shape? A shape tells how an object looks on the outside.
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
©A. Weinberg By Ms. Weinberg SOL ©A. Weinberg Let’s learn a bit about Geometry! Geometry is a part of Math that focuses on shapes and lines. Shapes.
9-4 Geometry in Three Dimensions  Simple Closed Surfaces  Regular Polyhedra  Cylinders and Cones.
GEOMETRY SOL Geometry 1 What is this shape called?
By: Emily Spoden. Trapezoid I’m a quadrangle that always has one pair of parallel lines.
Three-Dimensional Figures and Spatial Reasoning
Math Jeopardy For more information, click >>>>>> Where two faces meet edge.
TECH 104 – Technical Graphics Communication Week 13: 3D Modeling Basics.
Cubes, Prisms, Pyramids, Cylinders, Cones and Spheres
PROJECTIONS OF SOLIDS & SECTIONS OF SOLIDS
SECTIONS OF SOLIDS. ENGINEERING APPLICATIONS OF THE PRINCIPLES OF PROJECTIONS OF SOLIDS.
7.1 Three- Dimensional Figures I can classify and draw three-dimensional figures.
Chris Mayer & Nic Shulver Hidden Surface Wire frame drawings Wire frame drawings are quick to produce but are often confusing It is difficult to determine.
Vector Graphics Digital Multimedia Chap 이병희
Plane figure A two dimensional figure. Chapter 10.
MASUK INTRODUCTION In mathematics, solid geometry was the traditional name for the geometry of three-dimensional Euclidean space — for practical purposes.
Solid Modeling. Solid Modeling - Polyhedron A polyhedron is a connected mesh of simple planar polygons that encloses a finite amount of space. A polyhedron.
Unit 6 3D Modeling Concepts
Solid Geometry Polyhedron A polyhedron is a solid with flat faces (from Greek poly- meaning "many" and -edron meaning "face"). Each flat surface (or "face")
What are these shapes? squarecircletrianglerectangle How many sides do each have? How many points do each have?
Computer Graphics Rendering 2D Geometry CO2409 Computer Graphics Week 2.
An introduction to 3D Figures
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
COMP135/COMP535 Digital Multimedia, 2nd edition Nigel Chapman & Jenny Chapman Chapter 4 Lecture 4 - Vector Graphics.
Attributes A quality that is characteristic of someone or something.
Polygons and Solids. Helix - Volume or solid of spiral shape that turns at a constant angle. cylinder -Volume or solid generated by the rotation.
Introduction to Curves
Visible surface determination. Problem outline Given a set of 3D objects and a viewing specification, we wish to determine which lines or surfaces are.
7.1 Three- Dimensional Figures I can classify and draw three-dimensional figures.
Solid Geometry Student Expectations 7 th Grade: 7.3.6C Use properties to classify three- dimensional figures, including pyramids, cones, prisms, and.
Unit 4D:2-3 Dimensional Shapes LT5: I can identify three-dimensional figures. LT6: I can calculate the volume of a cube. LT7: I can calculate the surface.
Visible-Surface Detection Methods. To identify those parts of a scene that are visible from a chosen viewing position. Surfaces which are obscured by.
Introduction to 3D Solids and Solids of Revolution Some 3D shapes can be formed by revolving a 2D shape around a line (called the axis of revolution).
Three-dimensional figures, or solids, can be made up of flat or curved surfaces. Faces– the polygons that make the polyhedron Edges– A line segment formed.
GEOMETRY!!!. Points  A point is an end of a line segment.  It is an exact location in space.   It is represented by a small dot. Point A A.
Sphere – any round object whose curved surface is the same distance to the center as all of its points.
Digital Media Dr. Jim Rowan ITEC 2110 Vector Graphics II.
Lesson Plan: Drafting and Design J6-2. What is 3D solid modeling? How do 3D solid modeling programs work?
TECH 104 – Technical Graphics Communication Week 12: 3D Modeling Basics.
(1) Prism: It is a polyhedra having two equal and similar faces called its ends or bases, parallel to each other and joined by other faces which are rectangles.
3D Ojbects: Transformations and Modeling. Matrix Operations Matrices have dimensions: Vectors can be thought of as matrices: v=[2,3,4,1] is a 1x4 matrix.
Sections of Solids ME 111 Engineering Drawing. Sectional Views The internal hidden details of the object are shown in orthographic views by dashed lines.
Visible Surface Detection
Geometry Review By Mr. Hemmert.
Visit for more Learning Resources
ISOMETRIC PROJECTION RATHER DRAWING
Three-Dimensional Figures and Spatial Reasoning
10.1 Solid Geometry Geometry.
Geometry in our world Name:.
Solid Geometry.
Understanding Solid Figures
Dr. Jim Rowan ITEC 2110 Vector Graphics II
Solid Geometry.
Solid Geometry.
Welcome To Geometry ________ Jeopardy! with Mrs Ford.
Dr. Jim Rowan ITEC 2110 Vector Graphics II
Geometry: Three Dimensional Solids
Presentation transcript:

COM 366 Reading Data

COM 366 Reading data from disc files Organise the data in a logical fashion with comments as necessary. #Data for a cube # First the link data 12 1,2 2,3 3,4 4,1 1,5 2,6 3,7 4,8 5,6 6,7 7,8 8,5 #Now the node data 8 1,-1,1 -1,-1,1 -1,1,1 1,1,1 1,-1,-1 -1,-1,-1 -1,1,-1 1,1,-1 #Data for a cube # First the link data 12 1,2 2,3 3,4 4,1 1,5 2,6 3,7 4,8 5,6 6,7 7,8 8,5 #Now the node data 8 1,-1,1 -1,-1,1 -1,1,1 1,1,1 1,-1,-1 -1,-1,-1 -1,1,-1 1,1,-1

COM 366 Open filename For Input As #1 Input #1, temp_line While Left$(temp_line, 1)= "#" Input #1, temp_line Wend num_lines = Clnt(temp_line) ReDim L(2, num_lines) For i = 1 To num lines Input #1, L(1, i), L(2, i) Next i input #1, temp_line While Left$(temp_line, 1)= "#" Input #1, temp_line Wend num_points = Clnt(temp_line) ReDim X(num_points), Y(num_points), Z(num_points) For i = 1 To num_points Input #1, V(i).X, V(i).Y, V(i).Z Next i Close #1 A simple procedure to read the text file

COM 366 Topic 6 Data structures revisited

COM 366 (a) (b) (c) (d) Figure 6.1 Representing Objects with polygons

COM 366 OBJECT Node # Co-ordinates V1V1 V2V2 V3V3 VmVm x 1,y 1,z 1 x 2,y 2,z 2 x 3,y 3,z 3 x m,y m,z m Figure 6.2 : Object Data Structure  FACE LIST V 1,V 2,V 3,.... V 2,V 3,V 12,.... V 6,V 3,V 9,.... V 11,V 21,V 3,....  Face # F1F1 F2F2 F3F3 F4F4  Properties Colour, texture Appearance etc. “ “ “  Data structure for an object

COM 366 X Y Z CO X X Y Y Z Z H1OH1O H2OH2O GO X Y Z Figure 6.3 Local & global co-ordinates

COM 366 Scene Object 1Object 2 Object 3 Lighting Camera view Figure 6.4 Data structure for a scene

COM 366 Figure 6.5 Sweep generation of an object

COM 366 N = 6 N = 30 Axis of symmetry

COM 366 function RevObject(n) %To generate a 3D object from profile in 'goblet.txt' %NOTE this version only works with 5 nodes in the profile %First read in the data, set the number of nodes and faces U = dlmread('goblet.txt'); [a,b] = size(U); numnodes = a*n; numpatch = (a-1)*n; Node = zeros(numnodes,3); PSet = zeros(numpatch,4); %Now calculate all the node values for k = 0:n-1 for L = 1:a theta = 2*k*pi/n; Node(L+a*k,1) = U(L,1)*cos(theta); Node(L+a*k,2) = U(L,1)*sin(theta); Node(L+a*k,3) = U(L,2); end;

COM 366 for k = 1:n term = 5*(k-1); for L = 1:4 Pset(4*(k-1)+L,:) = [(term+L) (term+L+1) (term+L+6) (term+L+5)]; end end; %Finally ensure that the last but one profile connects to the first for k = numpatch-3:numpatch Pset(k,3)=Pset(k,3)-numnodes; Pset(k,4) = Pset(k,4) - numnodes; end %Uncomment the following line if you want to see the patch array %Pset patch('Vertices',Node,'Faces',Pset,'facevertexCdata',[ ],'facecolor','flat') axis square rotate3d on

COM 366 A BX Figure 6.3 Constructive solid geometry - 1

COM 366 Constructive solid geometry - 2 A B X Figure 6.4

COM 366 Constructive solid geometry - 3 A B A - B Figure 6.5 B - A

COM 366 [X,Y,Z] = cylinder [X,Y,Z] = cylinder(r) [X,Y,Z] = cylinder(r,n) Three forms of the cylinder function

COM 366 function [X,Y,Z] = Cone(R,h,L) %To create X,Y,Z data to draw a truncated cone. %R = base radius of the cone. %h = height to which the cone is drawn %L = apex of the cone %Note setting h = L will draw the full cone if nargin < 3, L = 1; end if nargin < 2, h = L; end if nargin == 0, R = 1; end stepsize = h/10; t = 0:stepsize:h; [X,Y,Z] = cylinder((R*(1-t/L))); When t = 0 then r = R When t = L then r = 0 Generating a cone

COM 366 h = L h < L Examples of cone

COM 366 Superquadratics Example the super ellipse m = 1 gives a normal ellipse m >1 gives a cusped figure m < 1 gives a ‘fatter figure m = 0 gives a rectangle

COM 366 Superquadratics in 3D (superquad)

COM 366 Using Fractals

COM 366 The Koch Curve N=0 N=1 N=2 N=5

COM 366 Length of the Koch Curve N =123 ……………m

COM 366 Dimension of the Koch Curve Definition of space dimension If N is the number of self similar copies required when an object is scaled by r then the Dimension of the object ‘D’ is given by : 1 = Nr D If a line is scaled by 1/3 then 3 copies are required thus the dimension of a line is 1 = 3(1/3) D. Therefore D = 1 If a square is scaled by 1/3 then 9 copies are required thus the dimension of a square is 1 = 9(1/3) D. Therefore D = 2 For the Koch curve if we scale by 1/3 we require 4 sections and the dimension is

COM 366 Using ‘graftals’ The correct name is parallel graph grammars Definitions (you can improvise your own) 1.A  AA 2.B  A[B]AA[B] 3.[ ] means ‘branch left If we start with A we generate a dull sequence A AA AAAA etc. But lets start with B and Record the first 3 generations : (0) B (1) A[B]AA[B] (2) AA[A[B]AA[B]]AAAA[A[B]AA[B]] B B B A A A BB BB A A A A A A AAA AAA

COM 366 Change the angle between turns and introduce () to mean branch right and we start to Get more interesting shapes

COM 366 Use curved segments and colour Finally add some random variation in angles and lengths Making ‘graftals’ realistic

COM 366 Modelling mountains P is a perturbation based on the length ‘s’ of the line e.g. 2 -s and R is a random number between 0 and In three dimensions the concept is exactly the same but using a triangle or pyramid as a starting point

COM 366 Add some colour and and shading !

COM 366 Topic 7 Hidden Surface Removal

COM 366 Convex Solids A solid is convex if a straight line joining any two points on the surface passes entirely through the body of the solid or through its surface. Examples of common convex solids include : Sphere, cube, cone, cylinder, pyramid All remaining solids are non convex

N L  Towards the viewer

COM 366 Criteria of Visibility The polygon surface is visible if 0    90 o or 270 o    360 o Or in terms of the angle cosine Cos(  )  0

COM 366 L = (L x,L y,L z ) Numerical evaluation of the visibility condition Viewing direction N = (N x,N y,N z ) Surface normal If these two vectors are of unit length then |L| = |N| = 1 When viewing along the z axis L reduces to (0,0,-1)

COM 366 Programming the visibility criterion My recommendation is that you add all the normals to your data structure (N X,N Y,N Z ) and then rotate them with the nodes before applying the visibility criterion

COM 366 Hidden Surface Removal for Non Convex Objects The painters ( or z buffer) algorithm If we can, in an unambiguous manner, sort the polygons into order of increasing z values then we can correctly render the object by drawing the polygons with the largest z values first. Remember that for a left handed co- ordinate system the polygons with the largest z value will be the furthest from the view point.

Test 1 : Do the X extents of P and Q not overlap ? Test2 : Do the Y extents of P and Q not overlap ? Test3 : Is P completely on the side of the plane of Q away from the viewer ? Test4 : Is Q completely on the side of the plane of P nearer to the viewer ? Test5 : Do the projections of the two polygons on the viewing plane not overlap ?

COM 366 The depth buffer method This method like the z buffer algorithm begins with a list of polygons but makes no attempt to sort the polygons by z depth instead two pixel based buffers are created. For each pixel position we store the current pixel colour in one buffer. The second buffer contains a single z value at each pixel position representing the depth of the currently displayed pixel.

COM 366 For all pixels Set pixel_colour = background Set pixel_depth = maximum_value End for all pixels For each polygon For each projected_polygon_pixel If z_co_ord < pixel_depth then Set pixel_colour = ploygon_colour Set pixel_depth = z_co_ord Endif End for each projected_polygon_pixel End for each polygon

COM 366

Type Vector x as single y as single z as single End type Type Vector x as single y as single z as single End type Type Polygon N as vector CR as integer CG as integer CB as integer V() as integer End Type Type Polygon N as vector CR as integer CG as integer CB as integer V() as integer End Type GLOBAL Object() as integer ‘The array of polygon numbers GLOBAL Poly() as Polygon‘ The array of polygons GLOBAL Node() as Vector‘ The array of vertex co-ordinates GLOBAL num_polygons, num_nodes as integer. GLOBAL Object() as integer ‘The array of polygon numbers GLOBAL Poly() as Polygon‘ The array of polygons GLOBAL Node() as Vector‘ The array of vertex co-ordinates GLOBAL num_polygons, num_nodes as integer. Programming in VB