TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
The Geometry of Virtual Worlds.pdf
1. The Geometry of
Virtual Worlds
Mrs. Rashmi Bhat
Assistant Professor
St. John College of Engineering and Management, Palghar
2. Topics to discuss
Geometric Models
Changing Position and Orientation
Axis-Angle Representations of Rotation
Viewing Transformations
Chaining the transformations
2
Prepared by Mrs. Rashmi Bhat
3. Geometric Models
• A model can be any object in a Virtual World.
• e.g. Chair, a tree, wall of room, user's avatar etc.
• Objects can be transformed
• Change in position
• Change in orientation
Prepared by Mrs. Rashmi Bhat 3
Change in position Change in Orientation
Object’s first View
Object’s Top View
Object’s another View
4. Geometric Models
• A virtual world can be represented in 3D Euclidean space with cartesian
coordinates
• Let represents a virtual world
• Every point is represented as a triple of real-valued coordinates: (𝒙, 𝒚, 𝒛)
• We follow right handed coordinate system
Prepared by Mrs. Rashmi Bhat 4
7. Geometric Models
• Geometric Models
• Are made of surfaces or solid regions in
• Contain infinite no. of points
• Are defined in terms of primitives
• Each primitive represents an infinite set of points
• e.g. 3D triangle
• Planar surface/ face of the triangle is specified by the coordinates of the
triangle vertices
( 𝑥 , 𝑦 , 𝑧 , 𝑥 , 𝑦 , 𝑧 , (𝑥 , 𝑦 , 𝑧 ))
Prepared by Mrs. Rashmi Bhat 7
8. Geometric Models
• Geometric Models
• A complicated object or body in the virtual world modelled using
numerous triangles can be arranged into a mesh.
Prepared by Mrs. Rashmi Bhat 8
9. Geometric Models
• Models representation in 3D mesh-triangle provokes many questions
1. How do we specify how each triangle "looks" whenever viewed by a user in VR?
2. How do we make the object "move"?
3. If the object surface is sharply curved, then should we use curved primitives?
4. Is the interior of the object part of the model, or does the object consist only of
its surface?
5. Is there an efficient algorithm for determining which triangles are adjacent to a
given triangle along the surface?
6. Should we avoid duplicating vertex coordinates that are common to
many neighboring triangles?
Prepared by Mrs. Rashmi Bhat 9
10. Geometric Models
• Data Structures
• Choice of data structure for geometric models should depend on which
operation will be performed on the model.
• Most commonly used data structure is Doubly Connected Edge List(DCEL) (also
known as Half-Edge data structure)
• Three kinds of data elements
• Face represents two dimensional part of the model
• Edge represents one dimensional part of the model
• Vertex represents zero dimensional part of the model
Prepared by Mrs. Rashmi Bhat 10
11. Geometric Models
Prepared by Mrs. Rashmi Bhat 11
Face
Vertex
Edge
Fig. Part of a doubly connected edge list
• Data Structures
• The data structure contains pointers
between adjacent faces, edges, and
vertices so that algorithms can
quickly traverse the model
components.
12. Geometric Models
• Inside vs Outside
• The model forms a complete barrier between the inside and outside of the
object.
• Coherent Model
• Use of high-end design tools like Blender/ Maya
• Why triangles?
• The simplest for algorithms to handle
• Complicated primitives may lead to smaller model sizes but increases the cost
of computation
Prepared by Mrs. Rashmi Bhat 12
13. Geometric Models
• Stationary vs Movable Models in Virtual World
• Stationary models, which keep the same co-ordinates forever.
• Movable models, which can be transformed into various positions and
orientations.
• Motion can be caused in following ways
• Using tracking system
• With the use of controllers
• Self-movement according to the laws of physics
Prepared by Mrs. Rashmi Bhat 13
14. Geometric Models
• Choosing Coordinate Axes
• Important to choose coordinates for the models
• Put origin (0,0,0) in a convenient location
• 𝑦 = 0 corresponds to the floor or sea level
• 𝑥 = 0 and 𝑧 = 0 can be in the center of virtual world
• For movable models the location of the origin and axes direction is very important
Prepared by Mrs. Rashmi Bhat 14
15. Geometric Models
• Viewing the models
• How the model will look on VR display?
• Two parts of the problem
• Determine where the points in a virtual world should appear on display
(Transformation)
• Determining how each part of the model should appear after taking into account
lighting sources and surface properties that are defined in the virtual world.
(Rendering)
Prepared by Mrs. Rashmi Bhat 15
17. Z
X
Y
Changing Position and Orientation
• Assume model is defined as a mesh of triangles.
• Changing position: Translation
• Changing orientation: Rotations
Prepared by Mrs. Rashmi Bhat 17
(0, 0, 0) X
Y
Z
18. Translation
• Consider a 3D triangle
• Amount to translate the position of a given triangle be , and along the
and axis respectively.
• The operation of changing position is called translation.
• It is given by
𝑥 , 𝑦 , 𝑧 ⟼ 𝑥 + 𝑥 , 𝑦 + 𝑦 , 𝑧 + 𝑧
𝑥 , 𝑦 , 𝑧 ⟼ 𝑥 + 𝑥 , 𝑦 + 𝑦 , 𝑧 + 𝑧
𝑥 , 𝑦 , 𝑧 ⟼ 𝑥 + 𝑥 , 𝑦 + 𝑦 , 𝑧 + 𝑧
Prepared by Mrs. Rashmi Bhat 18
19. Translation
• Here, , denotes that becomes replaced by after the transformation.
• This transformation will be applied to every triangle in a model.
• If the triangles are arranged in a mesh, then apply transformation to vertices
only.
Prepared by Mrs. Rashmi Bhat 19
21. Relativity
• Relativity
• Did the object move, or did the whole world move around it?
• If the origin moves, then users would move with it.
• If users perceive themselves as having moved, then VR sickness might increase,
even though it was the object that moved.
• User’s brains make their best guess as to which type of motion occurred, and
sometimes get it wrong
Prepared by Mrs. Rashmi Bhat 21
22. Rotation
• Many times we need to change the model’s
orientation in the virtual world.
• The operation that changes the orientation is
called rotation.
• Rotations in three dimensions are much more
complicated than translations.
Prepared by Mrs. Rashmi Bhat 22
23. Rotation
• 2D Linear Transformations
• Points in 2D virtual world have coordinates (𝑥, 𝑦)
• A generic 2 × 2 matrix
𝑀 =
𝑚 𝑚
𝑚 𝑚
• Multiplication of 𝑀 with a point (𝑥, 𝑦) results in a transformed point (𝑥 , 𝑦 )
𝑚 𝑚
𝑚 𝑚
𝑥
𝑦 =
𝑥
𝑦
the matrix multiplication yields
𝑥 = 𝑚 𝑥 + 𝑚 𝑦
𝑦 = 𝑚 𝑥 + 𝑚 𝑦
• 𝑀 is a transformation for which (𝑥, 𝑦) ⟼ (𝑥 , 𝑦 )
Prepared by Mrs. Rashmi Bhat 23
………(Eq. 1)
24. Rotation
• 2D Linear Transformations
• Applying the 2D matrix to points
• Lets take two points (1,0) and (0,1) lying one unit of distance from the origin
(0,0) on 𝑥 and 𝑦 axes respectively.
• Substitute these points in equation A, we get
𝑚 𝑚
𝑚 𝑚
1
0
=
𝑚
𝑚
and
𝑚 𝑚
𝑚 𝑚
0
1
=
𝑚
𝑚
If is applied to transform a model, each column of indicates precisely how
each coordinate axis is changed.
Prepared by Mrs. Rashmi Bhat 24
These special points select
the column vectors on 𝑴
25. Rotation
• 2D Linear Transformations
• Applying the 2D matrix to points
Prepared by Mrs. Rashmi Bhat 25
𝑀 =
(0,1)
(1,0)
𝑀 =
(0,1)
(−1,0)
Causes a flip
26. Rotation
• 2D Linear Transformations
• Applying the 2D matrix to points
Prepared by Mrs. Rashmi Bhat 26
𝑀 =
(0,2)
(2,0)
𝑀 =
(0,2)
(1,0)
Causes scaling Causes aspect
ratio distortion
27. Rotation
• 2D Linear Transformations
• Applying the 2D matrix to points
Prepared by Mrs. Rashmi Bhat 27
𝑀 =
(0, −1)
(−1,0)
𝑀 =
(1,1)
(1,1)
Causes a
mirror image
2D shape
collapses into 1D
28. Rotation
• 2D Linear Transformations
• Applying the 2D matrix to points
Prepared by Mrs. Rashmi Bhat 28
𝑀 =
(1,1)
(1,0)
𝑀 =
(0,1) (1,1)
Causes a skew
in X direction
Causes a skew
in Y direction
29. Rotation
• Which matrices produce rotations?
• Matrix must satisfy the following rules to produce rotation:
1. No stretching of axes
2. No shearing
3. No mirror images
Prepared by Mrs. Rashmi Bhat 29
30. Rotation
Rule 1: No stretching of axes
• To satisfy 1st rule, the columns of must have unit length
and
• Scaling and shearing transformation violates this rule
Rule 2: No Shearing
• To satisfy 2nd rule, the coordinate axes must remain perpendicular.
• The columns of indicates how axes are transformed, this rule implies that
their inner (dot) product is zero.
Prepared by Mrs. Rashmi Bhat 30
………(Eq. 2)
………(Eq. 3)
31. Rotation
Rule 3: No Mirror Images
• To satisfy 3rd rule, the determinant of is positive
• After satisfying first two rules, only possible remaining determinants are and
.
• Rule implies that
• Mirror image results in det 𝑀 = −1
Prepared by Mrs. Rashmi Bhat 31
………(Eq. 4)
32. Rotation
• 1st constraint indicate that each column of
must be chosen so that, its components lie on a
unit circle, centered at origin.
and
• Instead of and , use the notation of matrix
components.
Prepared by Mrs. Rashmi Bhat 32
(0,0)
1
33. Rotation
• Let and , substitute this into from Eq. 1 and by
applying Eq. 3 and Eq. 4, we get and
• Hence, Eq. 1 becomes
• The full range of allowable rotations can be generated by allowing to range
from to .
Prepared by Mrs. Rashmi Bhat 33
34. Rotation
Prepared by Mrs. Rashmi Bhat 34
• Degree of Freedom (DOF) of a rigid body is the number of independent
movement it has.
• e.g. 6 DOF movements
35. Rotation
• All four components of independently results in 4 DOFs.
• The constraints in 1st rule, each removes a DOF
• 𝑚 + 𝑚 = 1 and 𝑚 + 𝑚 = 1
• The constraint in 2nd rule removes another DOF
• 𝑚 𝑚 + 𝑚 𝑚 = 0
• 3rd rule does not remove any DOF, it eliminates half of the possible
transformations.
• Result is only one DOF parametrized by the angle .
• All possible 2D rotation can be interpreted as points along a unit circle.
Prepared by Mrs. Rashmi Bhat 35
36. Rotation
• 3D Case of Rotation
• Extension of the matrix from A from 2D to 3D results in 9 components
• Start with 9 DOFs and determine what matrices remain valid rotations.
Prepared by Mrs. Rashmi Bhat 36
………(Eq. 5)
38. Rotation
• 3D Case of Rotation
• Columns must have unit length.
• E.g. 𝑚 + 𝑚 + 𝑚 = 1
• Components of each column must lie on a unit sphere
• These rules remove 3 DOFs. (remaining DOFs = 6)
• Pairwise inner products of each columns must be zero
• e.g. by choosing first two columns, constraint is 𝑚 𝑚 + 𝑚 𝑚 + 𝑚 𝑚 = 0
• Apply the rule to remaining pairs.
• Each these cases eliminates a DOF, resulting in remaining 3DOFs only.
• Avoiding mirror images, det 𝑀 = 1 does not eliminate any DOF.
Prepared by Mrs. Rashmi Bhat 38
39. Rotation
• 3D Case of Rotation
• There are 3 degrees of rotational freedom.
• So it is possible to pick three independent parameters fro 3D rotation and then
derive all 9 components from them.
• Parameterizing 3D rotaions by constructing them from “2D-like” transformations.
Prepared by Mrs. Rashmi Bhat 39
41. Rotation
Yaw, Pitch and Roll
• Rotation about -axis
• Let be a counterclockwise rotation of about the 𝑧 axis.
• Rotation matrix is given by
• Upper left of matrix looks like 2D rotation matrix.
• This causes roll to behave like 2D rotation in the 𝑥𝑦 plane.
Prepared by Mrs. Rashmi Bhat 41
………(Eq. 6)
42. Rotation
Yaw, Pitch and Roll
• Rotation about -axis
• Let be a counterclockwise rotation of about the axis.
• Rotation matrix is given by
• Points are rotated with respect to and while the coordinate is left
unchanged.
Prepared by Mrs. Rashmi Bhat 42
………(Eq. 7)
43. Rotation
Yaw, Pitch and Roll
• Rotation about -axis
• Let be a counterclockwise rotation of about the axis.
• Rotation matrix is given by
• Points are rotated with respect to and while the coordinate is left
unchanged.
Prepared by Mrs. Rashmi Bhat 43
………(Eq. 6)
44. Rotation
• Combining Rotations
• The yaw, pitch, and roll rotations can be combined sequentially to attain any
possible 3D rotation
• The ranges of and are from to ; however, the pitch need only range
from to
Prepared by Mrs. Rashmi Bhat 44
45. Rotation
• Matrix multiplications are “backwards”
• Lets have a rotating point and two rotation matrices and
• If we rotate using , then
• If we then apply , we get
• Suppose, we combine two rotations first and then apply it to to get
• i.e. will give you different result
• Linear algebra reads right to left
• So we can combine first to obtain
•
Prepared by Mrs. Rashmi Bhat 45
46. Rotation
• Translation and Rotation in one Matrix
• Suppose we want to apply a rotation matrix , and follow it with a translation
by
𝑥
𝑦
𝑧
= 𝑅
𝑥
𝑦
𝑧
+
𝑥
𝑦
𝑧
• There is no way to form a single 3 by 3 matrix to accomplish both operations
• Homogeneous transformation matrix can be used
𝑅
𝑥
𝑦
𝑧
0 0 0 1
𝑥
𝑦
𝑧
1
=
𝑥
𝑦
𝑧
1
Prepared by Mrs. Rashmi Bhat 46
47. Rotation
• Inverting transforms
• To invert a translation, we apply the negation
𝑥
𝑦
𝑧
= 𝑅
𝑥
𝑦
𝑧
+
𝑥
𝑦
𝑧
• To invert rotation, we apply matrix inverse
• For rotation matrix 𝑅, the inverse is equal to the transpose 𝑅 = 𝑅
• Inverse of is
𝑅
0
0
0
0 0 0 1
1 0 0
0 1 0
0 0 1
𝑥
𝑦
𝑧
0 0 0 1
Prepared by Mrs. Rashmi Bhat 47
48. Axis Angle Representation of Rotation
• 3D rotation is complicated for several reasons
• Nine matrix entries are specified in terms of only three independent
parameters, and with no simple parameterization,
• The axis of rotation is not the same every time,
• The operations are non commutative, implying that the order of matrices is
crucial.
• Kinetic singularities
Prepared by Mrs. Rashmi Bhat 48