cmsc427 geometry and vectors review where are we
play

CMSC427 Geometry and Vectors Review: where are we? Parametric - PowerPoint PPT Presentation

CMSC427 Geometry and Vectors Review: where are we? Parametric curves and Hw1? Going beyond the course: generative art https://www.openprocessing.org Brandon Morse, Art Dept, ART370 Polylines, Processing and Lab0? Questions


  1. CMSC427 Geometry and Vectors

  2. Review: where are we? • Parametric curves and Hw1? • Going beyond the course: generative art • https://www.openprocessing.org • Brandon Morse, Art Dept, ART370 • Polylines, Processing and Lab0? • Questions on Processing? • https://processing.org • Learning Processing – Dan Shiffman

  3. How can we … • Find a line perpendicular to another? • Find symmetric reflecting vector on a mirror? • Find the distance from a point to a line? • Figure out if a facet is facing the camera?

  4. Polyline and points P3 P5 P1 P4 P2 P0 • Polyline as sequence of locations (points)

  5. Polyline and vectors V3 V5 V1 V4 V2 P0 • Polyline as point plus sequence of vectors • Assumption: displacements << locations, fewer bits

  6. Polyline as vectors V3 V5 V1 V4 V2 P0 P1 = P0+V1 P2 = P1+V1 = P0+V1+V2 • Polyline as point plus sequence of vectors • Assumption: displacements << locations, fewer bits

  7. Vector and vector operations • Objects: • Points (x,y) – represent position • Vector <x,y> – represent displacement, direction • Operations: • Vector addition, subtraction, scaling • Vector magnitude • Vector dot product • Vector cross product • Linear, affine and convex combinations • Applications: • Representations: using vectors for lines, planes, others • Metrics: angle between lines, distances between objects • Tests: are two lines perpendicular, is a facet visible?

  8. Vectors • Direction and distance • Describes a • Difference between points • Speed, translation, axes • Notation • In bold a P1 • Angle brackets a = <x,y> a =P1-P0 • Free vectors a P0 • No anchor point • Displacement, not location

  9. Vector scaling Multiplication by scalar s a a 0.5 a -1 a = - a

  10. Vector addition and subtraction a b -b b c = a - b a a c = a + b

  11. Vector addition and subtraction What is c in terms of a and b ? c a b

  12. Vector addition and subtraction What is c in terms of a and b ? a + c = b c a b

  13. Vector addition and subtraction What is c in terms of a and b ? a + c = b c c = b - a a a b b

  14. Coordinate vs. coordinate-free representation Coordinate-free equation c = b - a Valid for 2D and 3D Prefer when possible a b Coordinate equation a = <3,3> b = <4,2> c = b - a = <4,2> - <3,3> = <1,-1>

  15. Parametric line in coordinate-free vector format 𝑦 = 𝑢 𝑒𝑦 + 𝑞𝑦 𝑄1 𝑧 = 𝑢 𝑒𝑧 + 𝑞𝑧 t = 1 t = 0.75 Set 𝑄0 t = 0.5 𝑾 = 𝑄1 − 𝑄0 t = 0.25 =< 𝑒𝑦, 𝑒𝑧 > t = 0 Then 𝑄(𝑢) = 𝑢 𝑾 + 𝑄0 Good in 2D and 3D

  16. � Vector magnitude The magnitude (length) of a vector is v 4 = 𝑤 64 + 𝑤 74 𝑤 64 + 𝑤 74 v = A vector of length 1.0 is called a unit vector To normalize a vector is to rescale it to unit length n : = v v Normal vectors represent direction and are used for: light direction, surface normals, rotation axes

  17. Dot product • Inner product between two vectors • Defined using coordinate-free cosine rule 𝐛 • b = a b cos (𝜄) a θ b

  18. Dot product • Inner product between two vectors • Defined using coordinate-free cosine rule 𝐛 • b = a b cos (𝜄) a θ b • Example: 𝐛 =< 1,1 > 𝐜 =< 1,0 > a 𝜄 = π/2 θ=π/2 𝐛 • b = 1.4142 ∗ 1 ∗ 0.70711 = 1 b

  19. Dot product – coordinate version • Given 𝐜 = 𝒄 𝒚 , 𝒄 𝒛 𝐛 = 𝒃 𝒚 , 𝒃 𝒛 • Then 𝐛 • b = 𝒃 𝒚 𝒄 𝒚 + 𝒃 𝒛 𝒄 𝒛 • In n dimensions 𝒐 𝐛 • b = O 𝒃 𝒋 𝒄 𝒋 𝒋R𝟐

  20. Dot product – coordinate version • Given 𝐜 = 𝒄 𝒚 , 𝒄 𝒛 𝐛 = 𝒃 𝒚 , 𝒃 𝒛 • Then 𝐛 • b = 𝒃 𝒚 𝒄 𝒚 + 𝒃 𝒛 𝒄 𝒛 • Example revised: 𝐛 =< 1,1 > a 𝐜 =< 1,0 > θ=π/2 𝐛 • b = 1 ∗ 1 + 1 ∗ 0 = 1 b

  21. Dot product: computing angle (and cosine) • Given 𝐛 • b = a b cos (𝜄) • We have cos 𝜄 = 𝐛 • b a b 𝐛 • b 𝜄 = cos T𝟐 a b • Example 𝐛 =< 1,1 >, 𝐜 =< 1,0 > 𝐛 • b = 1 ∗ 1 + 1 ∗ 0 = 1 a a = 𝟐. 𝟓𝟐𝟓𝟑, b = 𝟐. 𝟏 𝐛 • b 𝟐 θ=π/4 a b = 𝟐. 𝟓𝟐𝟓𝟑 = 𝟏. 𝟖𝟏𝟖𝟐𝟐 𝐛 • b cos T𝟐 b = 𝟏. 𝟖𝟗𝟔𝟓𝟏 = 𝝆/𝟓 a b

  22. Dot product: testing perpendicularity • Since cos 90° = cos 𝜌 2 = 𝟏 • Then a perpendicular to b gives 𝐛 ⊥ b ⇒ 𝐛 • b = 0 • Examples 𝐛 =< 1,0 >, 𝐜 =< 0,1 > 𝐛 • b = 1 ∗ 0 + 1 ∗ 0 = 0 𝐛 =< 1,1 >, 𝐜 =< −1,1 > 𝐛 • b = 1 ∗ −1 + 1 ∗ 1 = 0

  23. Perp vector and lines • Given vector 𝐰 =< 𝑤 6 , 𝑤 7 > • The perp vector is =< −𝑤 7 , 𝑤 6 > • So 𝐰•𝐰 b = 0

  24. Midpoint bisector • Given line segment P0 to P1, what line is perpendicular through the midpoint? P1= (5,3) P0 = (1,1)

  25. Midpoint bisector • Given line segment P0 to P1, what line is perpendicular through the midpoint? P1= (5,3) v = P1-P0 n = v_perp/|v_perp| m = (P0+P1)/2 P0 = (1,1)

  26. Midpoint bisector • Result: bisector is 𝑄 = 𝑢 n + 𝑛 • With n normalized perp vector, m midpoint • Appropriate range of t? P1= (5,3) v = P1-P0 n = v_perp/|v_perp| m = (P0+P1)/2 P = t n + m P0 = (1,1)

  27. Midpoint displacement terrain (2D recursive algorithm) • Given two points P0,P1 • Compute midpoint m • Compute bisector line P = tn + m • Pick random t, generate P’ • Call recursively on segments P0-P’, P’-P1 • Tuning needed on magnitude of displacement

  28. Midpoint displacement terrain (3D recursive algorithm) P0 P1 • Start with four points P0,P1,P2,P3 • Divide (quads or triangles?) • Compute midpoint bisector (how?) • Displace, repeat P3 P2 Hunter Loftis

  29. Cross product a × b • Read as “a cross b” • a x b is a vector perpendicular to both a and b , in the direction defined by the right hand rule

  30. Cross product a × b • Read as “a cross b” • a x b is a vector perpendicular to both a and b , in the direction defined by the right hand rule • Vector a and b lie in the plane of the projection screen. • Does a x b p oint towards you or away from you? a What about b x a ? b

  31. Cross product: normal to plane P0 P1 • How compute normal vector to triangle P0, P1, P3? • Assume up is out of page P3 P2

  32. Cross product: normal to plane P0 P1 • How compute normal vector to triangle P0, P1, P3? • Assume up is out of page • One answer: n = (P1-P3) x (P0-P1) P3 P2

  33. Cross product: length of a x b • Parallelogram rule 𝐛 × b = a b sin (𝜄) • Area of mesh triangle? • When would cross product be zero? 𝐛 × b = 0

  34. Cross product: length of a x b • Parallelogram rule 𝐛 × b = a b sin (𝜄) • Area of mesh triangle? • When would cross product be zero? 𝐛 × b = 0 • Either a,b parallel, or either degenerate

  35. Cross product: computing, vector approach 𝑏 7 𝑐 h − 𝑏 h 𝑐 7 𝐛 × b = 𝑏 h 𝑐 6 − 𝑏 6 𝑐 h 𝑏 6 𝑐 7 − 𝑏 7 𝑐 6

  36. Cross product: computing, matrix approach 𝑗 𝑘 𝑙 • Determinant of 𝑏 6 𝑏 7 𝑏 h 𝐛 × b = 𝑐 6 𝑐 7 𝑐 h • Computed with 3 lower minors 𝑏 7 𝑏 h 𝑏 6 𝑏 7 𝑐 h − 𝑘 𝑏 6 𝑏 h 𝑐 h + 𝑙 𝐛 × b = 𝑗 𝑐 7 𝑐 6 𝑐 6 𝑐 7 𝑏 𝑐 • with 𝑒 = 𝑏𝑒 − 𝑑𝑐 𝑑 • i, j, k are unit vectors in directions of x, y and z axes • i=<1,0,0> j=<0,1,0> k=<0,0,1>

  37. Midpoint of triangle? P1 ? P2 P0

  38. Midpoint of triangle? Answer 1: P1 𝑛 = 𝑄0 + 𝑄1 + 𝑄2 3 ? P2 P0

  39. Midpoint of triangle? Answer 2: Double interpolation (blending) P1 First interpolation: vector line P0 to P1 𝑄 = 𝑢𝑊 + 𝑄0 m0 = 𝑢(𝑄1 − 𝑄0) + 𝑄0 P2 = 𝑢𝑄1 + (1 − 𝑢)𝑄0 Midpoint at t = 0.5 P0 𝑛0 = 0.5𝑄1 + (1 − 0.5)𝑄0 = 0.5𝑄1 + 0.5𝑄0 = 𝑄1 + 𝑄0 2

  40. Midpoint of triangle? Answer 2: Double interpolation P1 Second interpolation: vector line m0 to P2 𝑄 = 𝑡𝑊′ + 𝑛0 m0 = 𝑡(𝑄2 − 𝑛0) + 𝑛0 P2 m = 𝑡𝑄2 + 1 − 𝑡 𝑛0 Midpoint at s = 1/3 P0 𝑛0 = 1 3 𝑄2 + 1 − 1 = 1 3 𝑄2 + 2 3 𝑛0 3 (0.5𝑄1 + 0.5𝑄0) = 1 3 𝑄2 + 2 3 𝑛0 = 𝑄2 + 𝑄1 + 𝑄0 3

  41. � � Generalizing: convex combinations of points A convex combination of a set of points S is a linear combination such that the non-negative coefficients sum to 1 with and O 𝛽 t = 1 𝐷 = O 𝛽 t 𝑄 t 0 ≤ 𝛽 t ≤ 1 u tv w

  42. � � Generalizing: convex combinations of points A convex combination of a set of points S is a linear combination such that the non-negative coefficients sum to 1 O 𝛽 t = 1 𝐷 = O 𝛽 t 𝑄 t 0 ≤ 𝛽 t ≤ 1 with and u tv w Is this equation for a line segment a convex combination? 𝑄 = 𝑢𝑄1 + (1 − 𝑢)𝑄0

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend