Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.

Similar presentations


Presentation on theme: "Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College."— Presentation transcript:

1 Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College PowerPoint Instructor’s Resource

2 Mathematics for Modeling Some mathematics tools to help you develop your graphics programs

3 Mathematics is an Important Tool for Computer Graphics In this chapter we survey a number of topics that are each helpful in one or more places in graphics The presentation here may not be as deep as you would like, but you can consult mathematics textbooks for more The order is generally simpler to more complex, but is not systematic

4 What Is a 2D or 3D Space? We use 2D and 3D Euclidean space Our points are (x,y) or (x,y,z) They correspond to points in 2D or 3D space with X-Y or X-Y-Z coordinates We generally use right-hand coordinates (right) rather than left-hand ones (left)

5 Points Geometrically, a point is a position in space Algebraically, the point is defined by its coordinates (x,y) or (x,y,z) We will usually see points as vertices in a geometric object However, a triple (x,y,z) or a quadruple (x,y,z,w) will sometimes have another meaning, such as a color

6 Lines Lines are one-dimensional objects that are associated with a point and a direction vector The line through a given point P 0 in a given direction contains all points P so that the direction from P to P 0 is a scalar multiple of the direction vector If you have two points, the vector from one to the other can be the line’s vector

7 Lines (2) If you have two points P 0 and P 1, the line containing them can be expressed by for all possible real values of t ; this is called the parameter for the line This equation is about points, but you can easily turn this into equations about each component separately

8 Rays A ray is defined very much like a line, but only points that lie in the same direction as the line’s vector are included. This is given by the equation of the line except that we only allow values of the parameter t ≥ 0.

9 Line Segments A line segment is a portion of a line that is given by parameters t in [0,1] With the two-point approach, the line segment contains all the points between P 0 and P 1 When you define two adjacent vertices of a graphics object, the edge between them is a line segment

10 Line Segments (2) Often the parameter for a line segment will be very important, so we need to understand how parameters match their corresponding points

11 Parametric Curves A parametric curve is defined by three functions of one parameter x(t), y(t), z(t) For any value of t, the point (x(t), y(t), z(t)) is on the curve We will see a number of parametric curves in our work The parameter is often limited to [0,1]

12 Parametric Surfaces A parametric surface is defined by three functions of two parameters x(s,t), y(s,t), z(s,t) For any values of the parameters (s, t), the point (x(s,t), y(s,t), z(s,t)) is on the curve We will see even more parametric surfaces in our work The parameters are often limited to [0,1]

13 Vectors Vectors are much like points and are given by tuples of real numbers Geometrically, vectors represent directions rather than positions Vectors have length, given by A unit vector has length 1

14 Vector Operations Vectors have four primary operations –Addition (componentwise) –Scalar multiplication –Dot product –Cross product

15 Dot Product This operation takes two vectors and returns a scalar Operates by adding the componentwise products There are geometric meanings to the dot product

16 Dot Product (2) Geometrically, the dot product depends on the angle between the vectors –For any two vectors A and B, if theta is the angle between the vectors, –If two vectors have a dot product of zero, they are orthogonal (perpendicular to each other)

17 Dot Product (3) The dot product is very helpful when you consider the relationship between two vectors The length of the projection of a vector U onto a vector V is given by

18 Cross Product The cross product of two vectors yields another vector This vector is perpendicular to both of the original vectors The computation is given by a determinant calculation, but more simply:

19 Cross Product (2) Cross products are not commutative: Cross products are very handy when you want to compute a vector normal to two given vectors (e.g. vertex normals)

20 Reflection Vectors If you have a normal vector at a point and an incoming vector (e.g. a light vector), you may need to compute the reflection of the incoming vector This is given by

21 Transformations When we talked about modeling transformations, we focused on what they do rather than on how they are done If we talk about the mathematics, however, we must talk about how they work

22 Transformations (2) Transformations include scaling, translation, rotation Geometry is processed as 4-tuples (x,y,z,w) and all transformations are linear Thus transformations act as 4x4 matrices

23 Transformations (3) Scaling matrix Translation matrix

24 Transformations (4) Rotations are more complex, and we usually think of them only in terms of rotations around coordinate axes For the 2D case: the x -axis rotation R

25 Transformations (5) Rotations by around each axis: around X around Y around Z The Y case is different because of the axis order

26 Planes A plane can be defined several ways –A plane is determined by three points –Given a point P and a line L through P, a plane is the set of points X so that the line XP is perpendicular to L These are the same: the three points determine two lines, and the cross product of the lines determines the normal line

27 Planes (2) Equation of a plane can be derived from the second definition Or, working through this equation and collecting terms, we end up with Here the coefficients A, B, C are the components of the normal vector

28 Convex Polygons A polygon is complex if for any two points A and B in the polygon, the line between them is all in the polygon Alternately, a convex polygon is the convex sum of its vertices, or for all points P in the polygon, where all values of are in [0,1]

29 Convex Polygons (2) One convex polygon (left) and two that are not convex (middle and right)

30 Polar and Cylindrical Coordinates You can identify points in the plane by rectangular coordinates (x,y) or by angle and distance (r,  ) This can be extended to 3D by adding the z coordinate

31 Spherical Coordinates Use latitude and longitude along with distance Similar to identifying points in space by projecting them from the earth

32 Triangle-Based Collision Detection With objects built from triangles, to test for collisions you need only test for spherical and triangle collisions


Download ppt "Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College."

Similar presentations


Ads by Google