• No results found

TNM046: Datorgrafik Triangle and Normal

N/A
N/A
Protected

Academic year: 2021

Share "TNM046: Datorgrafik Triangle and Normal"

Copied!
9
0
0

Loading.... (view fulltext now)

Full text

(1)

TNM046: Datorgrafik Triangle and Normal

Sasan Gooran

VT 2013

(2)

Vertex and Triangle

Vertex: ( x y z )

Triangle: array of Vertex (vertices)

3D object: array of Triangle (triangles)

Example: Triangle[1] : (10,10,10), (10,20,10), (10,20,20) Triangle[2] : (10,10,10), (10,20,10), (10,10,20)

Not a good approach

(3)

3

Vertex and Triangle

Vertex: ( x y z )

Vertex table: array of Vertex

Triangle table: array of integers

Example: Vertex table: (10,10,10) , (10,20,10) , (10,20,20), (10,10,20), …..

Triangle table: (1,2,3) , (1,2,4) , ….

3D object: Vertex table + Triangle table

Now all vertices in the object is in one list (table).

(4)

Vertex and Triangle

Example: Present the following object using vertex and

triangle table. The distance from P1, P2 and P3 to the origin (P0) is unity (1).

y z

p0 p1

p2 p3

Triangle 1:

p0p1p3

Triangle 2:

p0p2p3

Triangle 3:

p1p2p3

Vertex table:

p0: (0,0,0) p1: (1,0,0) p2: (0,1,0) p3: (0,0,1) Answer:

Triangle table:

Triangle 0: (0,1,2) Triangle 1: (0,1,3)

(5)

5

Vertex and Triangle

Assume triangle 1 (p0p1p3).

p0 = (0,0,0), p1 = (1,0,0), p3 = (0,0,1),

x z

p0 p1

p3

d

0

d

1

d

2

Difference vectors:

d

0

= (1, 0, 0) − (0, 0, 0) = (1, 0, 0)

d

1

= (0, 0,1) − (1, 0, 0) = (−1, 0,1)

d

2

= (0, 0, 0) − (0, 0,1) = (0, 0, −1)

(6)

Triangle and Normal

x z

p0 p1

p3

d

0

d

1

d

2

y z

p0 p

p2 p3

Triangle 1:

p0p1p3

d

0

× 

d

1

= (1, 0, 0) × (−1, 0,1) =

ˆx ˆy ˆz

1 0 0

−1 0 1

= (0, −1, 0)

This normal vector points outwards (the object)

d

1

× 

d

2

= (−1, 0,1) × (0, 0, −1) = (0, −1, 0) d

2

× 

d

0

= (0, 0, −1) × (1, 0, 0) = (0, −1, 0)

(7)

7

Triangle and Normal

x z

p0 p1

p3

d

0

d

1

d

2

Triangle 1:

p0p1p3

N

1

= 

d

0

× 

d

1

= 

d

1

× 

d

2

= 

d

2

×  d

0

Three possible starting points For this triangle three lists are possible:

(0,1,3) or (1,3,0) or (3,0,1)

In order to calculate the normal pointing outwards:

Find the vector from the first point to the second (call A1) Find the vector from the second point to the third (call A2)

N

1

= 

A

1

× 

A

2

points outwards

(8)

Triangle and Normal

Triangle table: Let your thumb of the right hand stick out of the object. Pick the first point, then the sense of your fingers gives you the other two points in the right sequence.

y z

p0 p1

p2 p3

Triangle 1:

p0p1p3

Triangle 2:

p0p2p3

Triangle 3:

p1p2p3

Triangle table:

Triangle 0: (0,2,1) Triangle 1: (0,1,3) Triangle 2: (0,3,2) Triangle 3: (1,2,3)

Compare this triangle table with the one on page 4.

(9)

9

Triangle and Normal

Therefore the following 3D object can be defined as:

x

y z

p0 p1

p2 p3

Triangle table:

(0,2,1) (0,1,3) (0,3,2) (1,2,3)

Vertex table:

(0,0,0) (1,0,0) (0,1,0) (0,0,1)

References

Related documents

För att uppskatta den totala effekten av reformerna måste dock hänsyn tas till såväl samt- liga priseffekter som sammansättningseffekter, till följd av ökad försäljningsandel

The increasing availability of data and attention to services has increased the understanding of the contribution of services to innovation and productivity in

Generella styrmedel kan ha varit mindre verksamma än man har trott De generella styrmedlen, till skillnad från de specifika styrmedlen, har kommit att användas i större

Närmare 90 procent av de statliga medlen (intäkter och utgifter) för näringslivets klimatomställning går till generella styrmedel, det vill säga styrmedel som påverkar

I dag uppgår denna del av befolkningen till knappt 4 200 personer och år 2030 beräknas det finnas drygt 4 800 personer i Gällivare kommun som är 65 år eller äldre i

Det har inte varit möjligt att skapa en tydlig överblick över hur FoI-verksamheten på Energimyndigheten bidrar till målet, det vill säga hur målen påverkar resursprioriteringar

Detta projekt utvecklar policymixen för strategin Smart industri (Näringsdepartementet, 2016a). En av anledningarna till en stark avgränsning är att analysen bygger på djupa

DIN representerar Tyskland i ISO och CEN, och har en permanent plats i ISO:s råd. Det ger dem en bra position för att påverka strategiska frågor inom den internationella