Useful math for graphics and games Lots of math used in graphics and games Various concepts in this course: aliasing coordinate systems
Download ReportTranscript Useful math for graphics and games Lots of math used in graphics and games Various concepts in this course: aliasing coordinate systems
Useful math for graphics and games Lots of math used in graphics and games Various concepts in this course: aliasing coordinate systems homogeneous coordinates matrices quaternions vectors quantity expressing magnitude and direction often written with respect to a basis e.g., basis vectors i, j, k p = ai + bj + ck bj j i ai length of vector == magnitude p = ai + bj + ck |p| = sqrt(a*a + b*b + c*c) Normalized vector: magnitude is 1 Perpendicular to surface Specified at vertices in usual geometric models “How do you know if something is a vector?” In code – look at the type! XNA: Vector2, Vector3, Vector4 In math (or on slides) – may not have types → Has an arrow: x in bold (sometimes) ax + y very hard to see, I hate this notation use domain knowledge F=ma: which quantities are vectors? Often you want to extract components of a vector If written explicitly, p = ai + bj + ck, can refer to pieces by symbol If not… Index like arrays: p[0] Subscript to show what piece: px Special symbol for a unit vector (length 1): ^ so if we have ŵ, by definition |ŵ| = 1 Used sometimes in addition to arrow, sometimes alone Add components p = ai + bj + ck q = si + tj + uk p + q = (a + s) i + (b + t) j + (c + u) k p – q = p + (-q) vector inverse defined: q = si + tj + uk -q = (-s)i + (-t)j + (-u)k p = ai + bj + ck q = si + tj + uk p – q = (a – s) i + (b – t) j + (c – u) k Dot product magnitude of projection of one vector onto the other Cross product only defined for 3-vectors! vector perpendicular to arguments, with magnitude equal to area of the spanned parallelogram p = ai + bj + ck q = si + tj + uk p ∙ q = a*s + b*t + c*u scalar quantity p ∙ q = |p| |q| cos θpq Basic use: projection of one vector onto another Lighting: Collisions: classic diffuse shading: N∙L amount of velocity in arbitrary direction Vector reflection: R = V – 2 V ∙ N ( N/|N|) p = ai + bj + ck q = si + tj + uk p x q = (b*u – c*t)i + (c*s – a*u)j + (a*t – b*s)k new vector perpendicular to both starting vectors p x q = |p| |q| sin θpq n Conventionally, right handed coordinate system used Obtain surface normal for triangle use two vectors in plane, cross product is perpendicular also note, can find winding order (front or back facing) Calculate area of triangle In physics, cross product appears regularly torque = F x d F = q v x B for charged particle in magnetic field