Appendix: Geometry & Representation

caig.cs.nctu.edu.tw
  • No tags were found...

Appendix: Geometry & Representation

Computer GraphicsAppendix: Geometry and RepresentationCourse no. DIS4566National Chiao Tung Univ, TaiwanBy: I-Chen Lin, Assistant ProfessorTextbook: E.Angel, Interactive Computer Graphics, 4 thEd., Addison Wesley


Outline◦ Introduce the elements of geometry• Scalars• Vectors• Points◦ Define basic primitives• Line segments• Polygons◦ Dimension and basis◦ Coordinate systems◦ Introduce homogeneous coordinates


Basic Elements◦ Geometry:• the relationships among objects in an n-dimensional space• Computer graphics mainly focuses on threedimensions.◦ Want a minimum set of primitives fromwhich we can build more sophisticatedobjects◦ We will need three basic elements• Scalars• Vectors• Points


Vectors◦ Physical definition: a vector is a quantitywith two attributes• Direction• Magnitude◦ Examples include• Force• Velocity• Directed line segments◦ Most important example for graphics◦ Can map to other typesv


Vector Operations◦ Every vector has an inverse• Same magnitude but points in oppositedirection◦ Every vector can be multiplied by a scalar◦ There is a zero vector• Zero magnitude, undefined orientation◦ The sum of any two vectors is a vector• Use head-to-tail axiomvwv -v αvuv = u + w


Linear Vector Spaces◦ Mathematical system for manipulatingvectors◦ Operations• Scalar-vector multiplication u=αv• Vector-vector addition: w=u+v◦ Expressions such asv=u+2w-3r◦ Make sense in a vector space


Vectors Lack Position◦ These vectors are identical• Same length and magnitude◦ Vectors spaces insufficient for geometry• Need points


Points◦ Location in space◦ Operations allowed between points andvectors• Point-point subtraction yields a vector• Equivalent to point-vector additionv=P-QP=v+Q


Affine Spaces◦ Point + a vector space◦ Operations• Vector-vector addition• Scalar-vector multiplication• Point-vector addition• Scalar-scalar operations◦ For any point define• 1 • P = P• 0 • P = 0 (zero vector)


Lines◦ Consider all points of the form• P(α)=P 0 + α d• Set of all points that pass through P 0 in thedirection of the vector d


Parametric Form◦ This form is known as the parametricform of the line• More robust and general than other forms• Extends to curves and surfaces◦ Two-dimensional forms• Explicit: y = mx +h• Implicit: ax + by +c =0• Parametric:x(α) = αx 0 + (1-α)x 1y(α) = αy 0 + (1-α)y 1


Rays and Line Segments◦ α >= 0, ray leaving P 0 in the direction d◦ If we use two points to define v, thenP( α) = Q + α (R-Q)= Q+αv = αR + (1-α)Q◦ 0


Affine Sums◦ Consider the “sum” P=α 1 P 1 +α 2 P 2 +…..+α n P n◦ Can show by induction that this summakes sense iff α 1 +α 2 +…..α n =1in which case we have the affine sum ofthe points P 1 ,P 2 ,…..P n◦ If, in addition, α i >=0, we have the convexhull of P 1 ,P 2 ,…..P n


Convexity◦ Convex iff:• for any two points in the object all points on theline segment between these points are also inthe objectPPQQconvexnot convex


Convex Hull◦ Smallest convex object containingP 1 ,P 2 ,…..P n◦ Formed by “shrink wrapping” points


Planes◦ A plane can be defined by a point and twovectors or by three pointsvRuRQP(α,β)=R+αu+βvP(α,β)=R+α(Q-R)+β(P-Q)


Trianglesconvex sum of S(α) and Rconvex sum ofP and Qfor 0


Normals◦ Every plane has a vector n normal(perpendicular, orthogonal) to it◦ From point-two vector form P(α,β)=R+αu+βv,we know we can use the cross product tofind n = u × v and the equivalent form(P(α)-P) ⋅ n=0


Dot product◦ u = [x 1 , x 2 , x 3 ] T◦ v = [y 1 , y 2 , y 3 ] T◦ u • v = x 1 y 1 + x 2 y 2 +x 3 y 3 = |u||v|cosθ◦ Projectionvwuw==⎛⎜⎝( | v | cosθ) unit( u)vu • v ⎞⎟| u || v | ⎠ |⎛ u v ⎞⎜ •= ⎟u2⎜ u ⎟⎝ ⎠uu|


Cross Product◦ u = [x 1 , x 2 , x 3 ] T◦ v = [y 1 , y 2 , y 3 ] T◦ | u v | = |u||v||sinθ|w=u × v=⎡x⎢⎢x⎢⎣x231yyy312−−−xxx312yyy231⎤⎥ ⎥⎥ ⎦uvvu


Linear Independence◦ A set of vectors v 1 , v 2 , …, v n is linearlyindependent ifα 1 v 1 +α 2 v 2 +.. α n v n =0 iff α 1 =α 2 =…=0◦ If a set of vectors is linearly independent,we cannot represent one in terms of theothers◦ If a set of vectors is linearly dependent,as least one can be written in terms ofthe others


Dimension◦ Dimension of a space• In a vector space, the maximum number oflinearly independent vectors is fixed◦ Basis• In an n-dimensional space, any set of n linearlyindependent vectors form a basis for the space◦ Given a basis v 1 , v 2 ,…., v n , any vector v canbe written asv=α 1 v 1 + α 2 v 2 +….+α n v nwhere the {α i } are unique


Representation◦ Need a frame of reference to relate pointsand objects to our physical world.• For example, where is a point? Can’t answerwithout a reference system• World coordinates• Camera coordinates


Coordinate Systems◦ Consider a basis v 1 , v 2 ,…., v n◦ A vector is written v=α 1 v 1 + α 2 v 2 +….+α n v n◦ The list of scalars {α 1 , α 2 , …. α n }is therepresentation of v with respect to thegiven basis◦ We can write the representation as a rowor column array of scalarsa=[α 1 α 2 …. α n ] T =⎡α⎢⎢α⎢ .⎢α⎢⎣12n⎤⎥⎥⎥⎥⎥⎦


Example◦ v=2v 1 +3v 2 -4v 3◦ a=[2 3 –4] T◦ Note that this representation is withrespect to a particular basis


Coordinate Systems◦ Which is correct?vv◦ Both are because vectors have no fixedlocation


Frames◦ A coordinate system is insufficient torepresent points◦ If we work in an affine space we can adda single point, the origin, to the basisvectors to form a framev 2P 0v 1v 3


Representation in a Frame◦ Frame determined by (P 0 , v 1 , v 2 , v 3 )◦ Within this frame, every vector can bewritten asv=α 1 v 1 + α 2 v 2 +….+α n v n◦ Every point can be written asP = P 0 + β 1 v 1 + β 2 v 2 +….+β n v n


Confusing Points and VectorsConsider the point and the vectorP = P 0 + β 1 v 1 + β 2 v 2 +….+β n v nv=α 1 v 1 + α 2 v 2 +….+α n v nThey appear to have the similarrepresentationsp=[β 1 β 2 β 3 ] v=[α 1 α 2 α 3 ]vvpVector can be placed anywherepoint: fixed


A Single Representation◦ If we define 0•P = 0 and 1•P =P then we canwritev=α 1 v 1 + α 2 v 2 +α 3 v 3 = [α 1 α 2 α 3 0][v 1 v 2 v 3 P 0 ] TP = P 0 + β 1 v 1 + β 2 v 2 +β 3 v 3 = [β 1 β 2 β 3 1][v 1 v 2 v 3 P 0 ] T◦ Thus we obtain the four-dimensionalhomogeneous coordinate representationv = [α 1 α 2 α 3 0] Tp = [β 1 β 2 β 3 1] T


Homogeneous Coordinates◦ A three dimensional point [x yz] is given asp =[x’ y’ z’ w] T =[wx wy wz w] T◦ We return to a three dimensional point (forw≠0) byx←x’/w ; y←y’/w ; z←z’/w◦ If w=0, a vector.◦ Homogeneous coordinates replaces pointsin three dimensions by lines through theorigin in four dimensions.


Homogeneous Coordinates andComputer Graphics◦ Homogeneous coordinates are key to allcomputer graphics systems• All standard transformations (rotation,translation, scaling) can be implemented withmatrix multiplications using 4 x 4 matrices• Hardware pipeline works with 4 dimensionalrepresentations• For orthographic viewing, we can maintain w=0for vectors and w=1 for points• For perspective we need a perspective division


Change of Coordinate Systems◦ Consider two representations of a thesame vector with respect to two differentbases. The representations arewherea=[α 1 α 2 α 3 ]b=[β 1 β 2 β 3 ]v=α 1 v 1 + α 2 v 2 +α 3 v 3 = [α 1 α 2 α 3 ][v 1 v 2 v 3 ] T=β 1 u 1 + β 2 u 2 +β 3 u 3 = [β 1 β 2 β 3 ][u 1 u 2 u 3 ] T


Representing second basis in termsof first◦ Each of the basis vectors, u1,u2, u3, arevectors that can be represented in termsof the first basisu 1 = γ 11 v 1 +γ 12 v 2 +γ 13 v 3u 2 = γ 21 v 1 +γ 22 v 2 +γ 23 v 3u 3 = γ 31 v 1 +γ 32 v 2 +γ 33 v 3


Matrix FormThe coefficients define a 3 x 3 matrixM =⎡γ⎢⎢γ⎢⎣γ112131and the bases can be related bya=M T bsee text for numerical examplesγγγ122232γγγ132333⎤⎥⎥⎥⎦


Change of Frames◦ We can apply a similar process inhomogeneous coordinates to therepresentations of both points and vectorsv 2Consider two frames:(P 0 , v 1 , v 2 , v 3 )Q 0(Q 0 , u 1 , u 2 , u 3 ) P 0 v 1v 3u 1u 2◦ Any point or vector can be represented ineither frame◦ We can represent Q 0 , u 1 , u 2 , u 3 in terms of P 0 , v 1 ,v 2 , v 3u 3


Representing One Frame in Terms ofthe OtherExtending what we did with change of bases◦u1 = g11v1+g12v2+g13v3◦u2 = g21v1+g22v2+g23v3◦u3 = g31v1+g32v2+g33v3◦Q0 = g41v1+g42v2+g43v3 +g44P0defining a 4 x 4 matrixM =⎡γ⎢⎢γ⎢γ⎢⎣γ11213141γγγγ12223242γγγγ132333430⎤0⎥⎥0⎥⎥1⎦


Working with RepresentationsWithin the two frames any point or vectorhas a representation of the same forma=[α 1α 2b=[β 1β 2α 3α 4] in the first frameβ 3β 4] in the second framewhere α 4 =β 4 = 1 for points and α 4 =β 4 = 0 forvectors andThe matrix M is 4 x 4 and specifies an affinetransformation in homogeneous coordinates


Affine Transformations◦ Every linear transformation is equivalentto a change in frames◦ Every affine transformation preserveslines◦ However, an affine transformation hasonly 12 degrees of freedom because 4 ofthe elements in the matrix are fixed andare a subset of all possible 4 x 4 lineartransformations

More magazines by this user
Similar magazines