Mathematics for Computer Graphics Graphics Laboratory Korea University http://kucg.korea.ac.kr
Contents Coordinate Systems Points and Vectors Matrices Parametric vs. Nonparametric Representations http://kucg.korea.ac.kr
Coordinate Systems Rectangular (Cartesian) Polar Cylindrical Spherical x, y, z axes Typical coordinate system Right/left-hand system Polar Cylindrical Spherical http://kucg.korea.ac.kr
2D Rectangular Coordinate System x y x Coordinate origin at the lower-left screen corner Coordinate origin at the upper-left screen corner <Window Coordinate System> <Screen Coordinate System> http://kucg.korea.ac.kr
3D Rectangular Coordinate System Right-hand system Standard in most graphics packages Left-hand system Easy to know the distance from the viewer Video monitor coordinate system http://kucg.korea.ac.kr
Polar Coordinate System p(r,) r s x http://kucg.korea.ac.kr
Why Polar Coordinates in Circles? In rectangular system Irregular distribution of continuous points y y d d x x dx dx Constant Distance among the Adjacent Points Irregularly Distributed Adjacent Points Rectangular Coordinate System Polar Coordinate System http://kucg.korea.ac.kr
Cylindrical / Spherical System x z r p(r,, ) z y x r p(r,,z) Cylindrical Coordinate System Spherical Coordinate System http://kucg.korea.ac.kr
Points and Vectors Point: location, position Vector: direction from one point to another Represented by using magnitude and unit direction y P2 y2 V y1 P1 x x1 x2 http://kucg.korea.ac.kr
Vectors 3D Vector Vector addition and scalar multiplication z V y V x z y 3D Vector Vector addition and scalar multiplication http://kucg.korea.ac.kr
Dot Product / Inner Product Scalar Product Definition Properties Commutative Distributive |V2|cos V2 V1 Dot Product / Inner Product http://kucg.korea.ac.kr
Careful for its direction!!! Vector Product Definition Properties Anti-commutative Not associative Distributive V1 V2 V1 V2 u Cross Product / Outer Product Careful for its direction!!! http://kucg.korea.ac.kr
Plane Normal Calculation Frequently used in Back face detection Shading function Vector product between Two edges of the target polygon N = V1 × V2 P4 V2 P3 P0 V1 P2 P1 http://kucg.korea.ac.kr
Back Face Detection Not drawing the back faces to be culled Can make the drawing speed faster Scalar product between Eye direction Deye and face normal vector Ni If DeyeNi > 0 Fi is back face http://kucg.korea.ac.kr
Back Face Example Eye N4 N3 F4 F3 N2 N5 F2 F5 Eye Direction Deye(1,0) (-0.9, -0.1) N2 (-0.8, 0.2) N3 (-0.2, 0.8) N4 (0.3, 0.7) N5 (0.8, 0.2) F1 F2 F3 F4 F5 http://kucg.korea.ac.kr
Back Face Calculation F1 F2 F3 F4 F5 DeyeN1 = (1,0)(-0.9, -0.1) = -0.9 F1 is a front face F2 DeyeN2 = (1,0)(-0.8, 0.2) = -0.8 F2 is a front face F3 DeyeN3 = (1,0)(-0.2, 0.8) = -0.2 F3 is a front face F4 DeyeN4 = (1,0)(0.3, 0.7) = 0.3 F4 is a back face F5 DeyeN5 = (1,0)(0.8, 0.2) = 0.8 F5 is a back face http://kucg.korea.ac.kr
Back Face Culled Result N4 (0.3, 0.7) N3 (-0.2, 0.8) F4 F3 N2 (-0.8, 0.2) N5 (0.8, 0.2) F2 Eye Direction Deye(1,0) F5 Eye F1 N1 (-0.9, -0.1) http://kucg.korea.ac.kr
<Simple Shading Function> The amount of illumination depends on cos If the incoming light Iin is perpendicular to the surface Isurf is maximum, so the surface is fully illuminated = 0, cos = 1 N L Isurf: intensity of the surface Iin: intensity of the incident light k: surface reflection coefficient L: direction from the surface to a light source <Simple Shading Function> http://kucg.korea.ac.kr
Matrices Definition Scalar multiplication and matrix addition A rectangular array of quantities Scalar multiplication and matrix addition http://kucg.korea.ac.kr
Matrix Multiplication Definition Properties Not commutative Associative Distributive Scalar multiplication j-th column i-th row × m = l l (i,j) m n n http://kucg.korea.ac.kr
Matrix Transpose Definition Transpose of matrix product Interchanging rows and columns Transpose of matrix product http://kucg.korea.ac.kr
Determinant of Matrix Definition 2 2 matrix For a square matrix Combining the matrix elements to product a single number 2 2 matrix Determinant of nn matrix A (n 2) Determinant of N x N Matrix http://kucg.korea.ac.kr
Inverse Matrix Definition 2 2 matrix Properties Non-singular matrix If and only if the determinant of the matrix is non-zero 2 2 matrix Properties http://kucg.korea.ac.kr
Parametric vs. Nonparametric Representations Circle example in computer graphics radius 2, centered at the origin Parametric expression: x = 2cos, y = 2sin Nonparametric expression Implicit: , explicit: y y Which one is balanced? -2 2 x -2 -1 1 2 x Parametric Expression Interval of : /4 Nonparametric Expression Interval of x: 1 http://kucg.korea.ac.kr
Parametric Representation Easy to draw the shape of an object smoothly Just increase one parameter ex) The other parameters are automatically calculated by Especially for symmetric objects Circle, sphere, ellipsoid, etc. Preferred in computer graphics Nonparametric representation is used mainly in numerical analysis http://kucg.korea.ac.kr