Presentation is loading. Please wait.

Presentation is loading. Please wait.

Similar presentations


Presentation on theme: ""— Presentation transcript:

58 COMPUTER GRAPHICS SEPTEMBER 3, 2014 CS 482 – FALL 2014
VECTORS AND MATRICES PARAMETRIC EQUATIONS VECTORS DOT PRODUCT CROSS PRODUCT INTERSECTIONS

59 PARAMETRIC EQUATIONS PARAMETRIC FORM OF A LINE P1 P0
Given points P0 = (x0 , y0 , Z0 ) and P1 = (x1 , y1 , Z1 ), the segment between these points can be determined by the equation: Viewed in terms of the individual coordinates, this amounts to: t = 0.9 P(0.9) = 0.1P P1 P1 t = 0.25 P(0.25) = 0.75P P1 t = 1 P(1) = P1 t = 0 P(0) = P0 t = 0.5 P(0.5) = 0.5P P1 P0 CS 482 – FALL 2014 SEPTEMBER 3, 2014: VECTORS AND MATRICES PAGE 59

60 SEPTEMBER 3, 2014: VECTORS AND MATRICES
DEFINITION A vector is an array of values representing not a position, but a direction and a magnitude. Vectors may be added together, subtracted from each other, and scaled by a constant factor. u v u+v u-v -v For example, all of the vectors illustrated ABOVE are the same vector, but their positions vary. CS 482 – FALL 2014 SEPTEMBER 3, 2014: VECTORS AND MATRICES PAGE 60

61 DOT PRODUCT DEFINITION
v When placed at the same starting position, the angle between two vectors u and v can be determined by their dot product: The Pythagorean Theorem allows us to conclude the following: where  is the angle between the two vectors. Dot product positive: Acute angle Dot product zero: Right angle Dot product negative: Obtuse angle CS 482 – FALL 2014 SEPTEMBER 3, 2014: VECTORS AND MATRICES PAGE 61

62 DOT PRODUCT APPLICATION: DETERMINING INTERSECTIONS
Parametric equations and dot products are useful when trying to determine the intersection between two line segments. If N is a normal vector to segment Q (i.e., perpendicular to the vector between Q0 and Q1), then solve the following equation for t : If 0 ≤ t ≤ 1, then P(t) is the intersection. P0 P1 Q0 Q1 If t < 0, then there is no intersection. P0 P1 Q0 Q1 If t > 1, then there is no intersection. P0 P1 Q0 Q1 CS 482 – FALL 2014 SEPTEMBER 3, 2014: VECTORS AND MATRICES PAGE 62

63 CROSS PRODUCT DEFINITION
When placed at the same starting position, a normal vector between two vectors u and v (i.e., a vector perpendicular to both u and v) can be determined by their cross product: u  v u v where k is the unit vector in the positive z direction. Again, the Pythagorean Theorem allows us to conclude that: where  is the angle between the two vectors. (Recall that the “right-hand rule” applies, so v  u = -u  v.) CS 482 – FALL 2014 SEPTEMBER 3, 2014: VECTORS AND MATRICES PAGE 63

64 CROSS PRODUCT APPLICATION: POLYGON CONVEXITY
A polygon is convex the segment between any two points on its boundary is completely contained within the polygon. Some graphical algorithms depend on polygons being convex. To determine whether a polygon is convex, take the cross product of each pair of vectors between consecutive vertex triples. If all of these cross products have the same sign, then the polygon is convex. Positive cross product Positive cross product Positive cross product Positive cross product Positive cross product Negative cross product Positive cross product Positive cross product Positive cross product Positive cross product CS 482 – FALL 2014 SEPTEMBER 3, 2014: VECTORS AND MATRICES PAGE 64

65 INTERSECTIONS n Q P RAY-PLANE INTERSECTION
A ray may be defined by specifying a starting point P and a direction vector d: The plane that passes through point Q and that has normal vector n may be defined as all points X such that: Q n The intersection between the ray and the plane then becomes the point on the ray that’s also in the plane: P And this occurs when: CS 482 – FALL 2014 SEPTEMBER 3, 2014: VECTORS AND MATRICES PAGE 65


Download ppt ""

Similar presentations


Ads by Google