350 likes | 566 Views
CSC 341 Introduction to Computer Graphics. Geometry: Coordinate Frames. Objectives. Introduce concepts such as dimension and basis Introduce coordinate systems for representing vectors spaces and frames for representing affine spaces Discuss change of frames and bases
E N D
CSC 341 Introduction to Computer Graphics Geometry: Coordinate Frames
Objectives • Introduce concepts such as dimension and basis • Introduce coordinate systems for representing vectors spaces and frames for representing affine spaces • Discuss change of frames and bases • Introduce homogeneous coordinates
Vector representation • A vector can be represented by a column of scalars
Linear Independence • A set of vectors v1, v2, …, vn is linearly independent if a1v1+a2v2+.. anvn=0 iff a1=a2=…=0 • If a set of vectors is linearly independent, we cannot represent one in terms of the others • If a set of vectors is linearly dependent, as least one can be written in terms of the others
Dimension and Basis • In a vector space, the maximum number of linearly independent vectors is fixed and is called the dimension of the space • In an n-dimensional space, any set of n linearly independent vectors form a basis for the space • Given a basis v1, v2,…., vn, any vector v can be written as v=a1v1+ a2v2+….+anvn where the {ai} are unique
Example v are two linearly independent vectors in 2D
Example v
Consider 3-space (3D) • Standard Basis: composed of 3 unit vectors, usually referred by the corresponding coordinate vectors. • Unit length • Mutually orthogonal z x y
Representation of vectors • Consider a basis v1, v2,…., vn • Any vector v is written v=a1v1+ a2v2+….+anvn • The list of scalars {a1, a2, …. an}is the representation ofvwith respect to the given basis • We can write the representation as a row or column array of scalars These are the cartesian coordinates of vector v [a1a2 …. an]T=
Example • v=2v1+3v2-4v3 • [2 3 –4]T • Note that this representation is with respect to a particular basis
Basis • Which is correct? • Both are because vectors have no fixed location v v
Coordinate Frames • A set of basis vectors is insufficient to represent points • If we work in an affine space we can add a single point, the origin, to the basis vectors to form a coordinate frame • Hence, a coordinate frame for n-space consists of a point called origin and n linearly independent vectors. v2 v1 P0 v3
ey ex P0=(0,0) Example: Standard Coordinate Frame in 2D P
ex ey P0=(0,0) Example: Standard Coordinate Frame in 2D • Observe that P - P0 = b1ex+ b2ey is a vector P
ex ey P0=(0,0) Example: Standard Coordinate Frame in 2D • Every point can be written as P = P0 + b1ex+ b2ey are the cartesian coordinates of point P P
Representation in a Frame • In general, frame determined by (P0, v1, v2, v3 ,…,vn) • Within this frame, every vector can be written as v=a1v1+ a2v2+….+anvn • Every point can be written as P = P0 + b1v1+ b2v2+….+bnvn are the cartesian coordinates of point P [b1b2 …. bn]T=
Confusing Points and Vectors Consider the point and the vector P = P0 + b1v1+ b2v2+….+bnvn v=a1v1+ a2v2+….+anvn They appear to have the similar representations p=[b1 b2 b3] v=[a1 a2 a3] which confuses the point with the vector A vector has no position v p v Vector can be placed anywhere point: fixed
Represent P and w with respect to Frame F and Frame G w P G.e1 F.e1 G.O G.e0 F.e0 F.O
Represent P and w with respect to Frame F and Frame G P G.e1 w F.e1 G.e0 F.e0
W[F] • W[F] =
Represent P and w with respect to Frame F and Frame G P P - F.O G.e1 F.e1 G.e0 F.e0
P[F] • P[F] =
A Single Representation If we define 0•P = 0 and 1•P =P then we can write w=2 F.e0 +1F.e1 + 0 •F.0 P=3 F.e0 +2F.e1 + 1 •F.0 Thus we obtain the homogeneous coordinate representation Homeogeneous coordinate is 0 for vectors, 1 for points • P[F] = W[F] =
In 3D v=a1v1+ a2v2+a3v3 = [a1 a2a30][v1 v2 v3 P0] T P = P0 + b1v1+ b2v2+b3v3= [b1 b2b31][v1 v2 v3 P0] T Thus we obtain the four-dimensional homogeneous coordinate representation v = [a1 a2a30] T P = [b1 b2b31] T
In general • In n-dimensional space, a vector or point is represented by a column of n+1 scalars
Homogeneous Coordinates and Computer Graphics • Homogeneous coordinates are key to all computer graphics systems • All standard transformations (rotation, translation, scaling) can be implemented with matrix multiplications using 4 x 4 matrices • Hardware pipeline works with 4 dimensional representations • All point-vector operations behave accordingly
Error checking by homogeneous coordinate • Consider • v = Q – P = • Valid operation • Try vector-vector addition, u + v • Homogeneous coordinate of result is 0: valid operation • Try scalar-vector multiplication • Homogeneous coordinate of result is 0: valid operation • Try point point addition • Homogeneous coordinate of result is 2: illegal operation P = [321]T Q = [511]T [2-10]T
Matrices • n x m array of scalars • n rows • m columns
Matrix operations • Scalar-matrix multiplication: multiply all elemnts of the matrix by the scalar • Matrix-matrix addition: add corresponding elements of the two matrices • C = A+B =[aij + bij ]
Matrix matrix multiplication • C = A.B = [cij ] • A is m X p • B is p X n
Matrix operations rules • a(bA) = (ab)A • abA = baA • A+B = B+A • A+(B+C) = (A+B) +C • A(BC) = (AB)C • AB = BA • AI = A • Where I is the identity matrix, 1’s on the diagonal, 0’s elsewhere • IB = B • (AB)T = BT AT • A.A-1 = I
Change of Representations • Converting point/vector representation from one coordinate frame to the other?