| Vectors |
| Example Vectors |
| |
Geometric Vectors |
| |
|
Directed Line Segments |
| |
|
Scalar-Vector Multiplication |
| |
|
|
Changes Length |
| |
|
|
Changes Length |
| |
|
Vector-Vector Addition |
| |
|
|
Head-to-Tail Axiom |
| Euclidean Spaces
|
| |
Inner (dot) product |
| |
|
u·v=v·u |
| |
|
(au+bv)·w=au·w+bv·w |
| |
|
v·v>0(v!=0) |
| |
|
0·0=0 |
| |
|
if u·v=0, then u and v orthogonal |
| |
|v|=sqrt(v·v) |
| |
Add concepts of affine spaces, such as
points |
| |
P-Q is a vector |
| |
|P-Q|=sqrt((P-Q)·(P-Q)) |
| |
Angle between two vectors |
| |
|
u·v=|u||v|cos(theta) |
| |
Equation for a circle |
| |
|
|Q-P|=r |
| |
|
sqrt((Q-P)·(Q-P))=r |
| |
|
(Q-P)·(Q-P)=r2 |
| Dot Product |
| Projections |
| |
Finding the shortest distance between a
point to a line or plane |
| |
Start with two vectors |
| |
Divide one into two parts |
| |
|
One parallel , one orthogonal to the second
original vector |
| |
v is first vector, w is second vector |
| |
w=av+u |
| |
Parallel part, v |
| |
Orthogonal part, u |
| |
u·v=0 |
| |
w·v=av·v+u·v=av·v |
| |
a=-(w·v)/(v·v) |
| |
av is projection of w onto v |
| |
u=w-[(w·v)/(v·v)]v |
| Normalized Vectors |
| |
Length of One |
| |
Unit vector |
| |
v'=v/||v|| |
| Normalized Vectors |
| OpenGL and Affine Spaces |
| |
Positions always defined relative to the
origin of the current coordinate system |
| |
Transform the coordinate system to take
positions relative to some other point |
| |
Necessary for computing distances, angles,
etc. |
| Matrices |
| |
nxm array of scalars |
| |
|
n Rows |
| |
|
m Columns |
| |
If m=n then square matrix |
| |
The elements of a matrix A are {aij}, i=1,...,n,
j=1,...,n |
| |
A=[aij] |
| |
Transpose of A of n is mxn matrix with rows
and columns interchanged |
| |
AT=[aji] |
| |
Single row or single column |
| |
|
Row Matrix |
| |
|
Column Matrix |
| |
b=[bi] |
| |
Transpose of a row matrix is a column matrix |
| |
Transpose of a column matrix is a row matrix |
| Matrices |
| Identity Matrix |
| |
1's along diagonal |
| |
I=[aij] aij={1 if i=j, 0 otherwise |
| |
AI=A |
| |
IB=B |
| Matrix Operations |
| |
Scalar-matrix multiplication |
| |
|
aA=[aaij] |
| |
|
a(bA)=(ab)A |
| |
|
abA=baA |
| |
Matrix-matrix addition |
| |
|
C=A+B=[aij+bij] |
| |
|
Commutative |
| |
|
Associative |
| |
Matrix-matrix multiplication |
| |
|
Product of nxl and lxm is nxm |
| |
|
Middle dimmension MUST match |
| |
|
C=AB=[cij] |
| |
|
cij=Sum[k=1,l]aikbkj |
| |
|
Associative |
| |
|
NOT Commutative |
| |
|
|
AB!=BA |
| |
|
|
May in fact not even be defined |
| |
|
|
Order matters |
| |
|
|
Application to Transformations |
| Row and Column Matrices |
| |
Re presentation of vectors or points |
| |
p=[x y z]T |
| |
pT=[x y z] |
| |
Transformation - Square matrix |
| |
Point -
Column matrix of 2, 3, or 4 pts |
| |
p'=Ap |
| |
|
Transforms p
by A |
| |
p'=ABCp |
| |
|
Concatenations of transformations |
| |
(AB)T=BTAT |
| Cross
Product |
| |
Provides a
vector orthogonal to two others |
| |
|
w=uxv=[a2b3-a3b2
a3b1-a1b3 a1b2-a2b1]T |
| |
Magnitude
provides sine of angle between u and v |
| |
|
|sin(theta)|=|uxv|/|u||v| |
| Cross
Product |
| Applications
to 3 D Graphics |
| |
Vertex |
| |
Matrix |
| |
|
Identity |
| |
|
Rotation |
| |
|
Translation |
| |
|
Scale |
| |
|
Projection |
| |
Mathematics |
| |
|
Multiplication |
| |
|
Dot Product |
| |
|
Cross Product |
|
Homogeneous Coordinates |
| |
In affine spaces points and vectors can be confused |
| |
|
P=[x y z]T |
| |
|
V=[x y z]T |
| |
Instead use |
| |
|
P=[x y z P0]T |
| |
|
|
P=a1v1+a2v2+a3v3+P0 |
| |
|
V=[x y z 0]T |
| |
|
|
V=b1v1+b2v2+b3v3 |
| |
Affine transformations preserve lines |
|
Points |
|
Line Equations |
| |
y-y1=m(x-x1), three equations in 3D |
| |
|
Point- Slope Form |
| |
|
m=slope, (x,y)=point 0, (x1, y1)=point 1 |
| |
L=Q+tw |
| |
|
Point-Normal Form |
| |
|
L is the line |
| |
|
Q is a point on the line |
| |
|
t is the unknown |
| |
|
w is a directional vector for the line |
| |
|
w must be from one point to another |
| |
|
w=P2-Q where P2 is the second point |
|
Plane Equations |
| |
p=ax+by+cz+d |
| |
|
Three point form |
| |
|
p is the plane |
| |
|
N=[p2-p1]x[p3-p1]=[a,b,c]T (cross product) |
| |
|
N*P1=-D (dot product) |
| |
p=(X-P)·v=0 |
| |
|
Point-Normal form |
| |
|
X is unknown |
| |
|
P is point on plane |
| |
|
v is normal to plane |
|
Line-Plane Intersections |
| |
Substitute for x ,y, or z in 3 point form |
| |
|
Works well for slope intercept form |
| |
Substitute line for X in point normal form |
| |
|
Works well when line in point normal form |
| |
|
Carried out: t=(((P-Q)·v)/(w·v))w |
| |
|
Intersection point at: Q+(((P-Q)·v)/(w·v))w |
| |
t is time (unknown) |
| |
v,w are vectors |
| |
Q,P,X are points |
|
Translation Matrix |
|
Rotation Matrix |
|
Scaling Matrix |
Simple Perspective
Projection Matrix |
|
Mutiple Transformations |
| |
Rotate about fixed point |
| |
|
S=(T)R(-T)p |
| |
Instance Transformation |
| |
|
Multiple uses of Same object |
| |
|
M=TRS |
| |
Order of operations |
| |
|
Right to left - fewer component operations |
| |
|
Precalculate matrix ops |
| |
|
Not unique effect but resulting matrix is |
| |
Rotations relative to another angle |
| |
|
Translate to origin |
| |
|
Rotate to align with current orientation |
| |
|
Rotate by specified amount |
| |
|
Rotate to unalign with orientation |
| |
|
R=T(p0)Rx(-Ox)Ry(-Oy)Rz(O)Ry(Oy)Rx(Ox)T(-p0) |
| |
Rotation about an arbitrary axis |
| |
|
Rotate to the axis first |
| |
|
Apply a rotation to the rotation |
| |
|
Brings it into the correct frame of reference or orientation first |
|
OpenGL |
| |
Provides 2 Frames |
| |
|
Camera frame, fixed |
| |
|
World frame |
| |
Current Transformation Matrix |
| |
|
Applied to everything |
| |
|
Changing CTM changes state of environment |
| |
|
4x4 Matrix |
|
OpenGL Matrix Operations |
| |
Replacement Matrices |
| |
|
glLoadIdentity() |
| |
|
glLoadMatrixf(pointer to matrix); |
| |
Matrix Transformations |
| |
|
glRotatef(angle, vx, vy, vz); |
| |
|
glTranslatef(dx, dy, dz); |
| |
|
glScalef(sx, sy, sz); |
| |
|
glMultMatrixf(myarray); |
| |
Rotation about a fixed point |
| |
|
glMatrixMode(GL_MODELVIEW); |
| |
|
glLoadIdentity(); |
| |
|
glTanslatef(4.0, 5.0, 6.0); |
| |
|
glRotatef(45.0, 1.0, 2.0, 3.0); |
| |
|
glTranslatef(-4.0, -5.0, -6.0); |
| |
Matrices are generated left to right |
| |
Matrix farthest to the right is applied first |
|
Matrix Stacks |
| |
Saving of states |
| |
Transform only part of a scene |
| |
|
Scale a single object |
| |
|
Rotate a heirarchical object |
| |
|
Apply transformation then restore original state |
| |
|
glPushMatrix(); |
| |
|
glScalef(3.0, 4.0, 5.0); |
| |
|
/* Draw Scaled Object */ |
| |
|
glPopMatrix(); |