introduction to computer graphics modeling 1
play

Introduction to Computer Graphics Modeling (1) April 16, 2020 - PowerPoint PPT Presentation

Introduction to Computer Graphics Modeling (1) April 16, 2020 Kenshi Takayama Some additional notes on quaternions 2 Another explanation for quaternions (overview) 1. Any rotation can be decomposed into even number of reflections 2.


  1. Introduction to Computer Graphics – Modeling (1) – April 16, 2020 Kenshi Takayama

  2. Some additional notes on quaternions 2

  3. Another explanation for quaternions (overview) 1. Any rotation can be decomposed into even number of reflections 2. Quaternions can concisely describe reflections in 3D 𝑦 = βˆ’ βƒ— 𝑦 βƒ— 𝑔 #$ 𝑆 βƒ— " βƒ— 𝑔 βƒ— 3. Combining two reflections equivalent to the rotation leads to the formula = cos $ % + πœ• sin $ 𝑦 cos $ % βˆ’ πœ• sin $ 𝑆 ! 𝑆 βƒ— # βƒ— 𝑦 βƒ— % % 3

  4. Any rotation can be decomposed into even number of reflections β€’ Mathematically proven πœ„ β€’ Valid for any dimensions R $! # ! ! " " β€’ Not unique (of course!) ! # R πœ„ One way R πœ„ R R ! " Another way R 4

  5. Quaternions recap β€’ Complex number: real + imaginary 𝑏 + 𝑐 𝐣 β€’ Quaternion: scalar + vector 𝑏 + βƒ— 𝑀 β€’ Definition of quaternion multiplication: Scalar part Vector part 𝑏 ! + 𝑀 ! 𝑏 " + 𝑀 " ≔ 𝑏 ! 𝑏 " βˆ’ 𝑀 ! β‹… 𝑀 " + 𝑏 ! 𝑀 " + 𝑏 " 𝑀 ! + 𝑀 ! ×𝑀 " β€’ Pure vectors can take multiplication by interpreting them as quaternions: 𝑀 ! 𝑀 " = βˆ’π‘€ ! β‹… 𝑀 " + 𝑀 ! ×𝑀 " β€’ Notable properties: 𝑀 βƒ— 𝑀 #! = βˆ’ 𝑀 " 𝑀 βƒ— βƒ— 𝑀 = βˆ’ βƒ— βƒ— If βƒ— 𝑀 β‹… π‘₯ = 0 , then βƒ— 𝑀 π‘₯ = βˆ’π‘₯ βƒ— 𝑀 β€’ (Relevant later) 𝑀 " βƒ— 𝑀× βƒ— βƒ— 𝑀 is always zero Multiplying βƒ— 𝑀 to rhs produces 1 𝑀 π‘₯ = βƒ— βƒ— 𝑀×π‘₯ = βˆ’π‘₯Γ— βƒ— 𝑀 = βˆ’π‘₯ βƒ— 𝑀 5

  6. Describing reflections using quaternions β€’ Reflection of a point βƒ— 𝑦 across a plane orthogonal to βƒ— 𝑦 βƒ— 𝑔 : βƒ— 𝑔 𝑦 ≔ βˆ’ βƒ— 𝑦 βƒ— 𝑔 #$ 𝑆 βƒ— " βƒ— 𝑔 βƒ— 𝑃 β€’ Holds essential properties of reflections: β€’ Linearity : 𝑆 βƒ— # βƒ— 𝑦 𝑆 βƒ— ' 𝑏 βƒ— 𝑦 + 𝑐 βƒ— 𝑧 = 𝑏 𝑆 βƒ— ' βƒ— 𝑦 + 𝑐 𝑆 βƒ— ' βƒ— 𝑧 β€’ βƒ— 𝑔 gets mapped to βˆ’ βƒ— 𝑔 : 𝑔 () = βˆ’ βƒ— ' βƒ— 𝑔 = βˆ’ βƒ— 𝑔 βƒ— 𝑔 βƒ— 𝑆 βƒ— 𝑔 𝑦 β‹… βƒ— β€’ If a point βƒ— 𝑦 satisfies βƒ— 𝑔 = 0 (i.e. on the plane), βƒ— 𝑦 doesn’t move: 𝑔 () = βˆ’ βˆ’ βƒ— 𝑔 () = βƒ— 𝑦 = βˆ’ βƒ— 𝑦 βƒ— 𝑦 βƒ— βƒ— 𝑆 βƒ— ' βƒ— 𝑔 βƒ— 𝑔 𝑦 𝑦 β‹… βƒ— 𝑔 = 0 , then βƒ— 𝑦 βƒ— Because if βƒ— 𝑔 βƒ— 𝑦 = βˆ’ βƒ— 𝑔 6 https://math.stackexchange.com/a/7263

  7. Setup for rotation around arbitrary axis 𝑧 βƒ— β€’ Rotation axis (unit vector) : πœ• πœ„ β€’ Rotation angle : πœ„ 𝑦 βƒ— β€’ Point before rotation : βƒ— 𝑦 β€’ Point after rotation : βƒ— 𝑧 ≔ 𝑆 %, ' βƒ— 𝑦 β€’ Think of local 2D coordinate system : πœ• β‹… βƒ— 𝑦 πœ• β€’ β€œRight” vector : 𝑣 ≔ βƒ— 𝑦 βˆ’ πœ• β‹… βƒ— 𝑦 πœ• 𝑀 βƒ— β€’ β€œUp” vector : βƒ— 𝑀 ≔ πœ•Γ— βƒ— 𝑦 β€’ Note that 𝑣 = 𝑀 βƒ— 𝑣 β€’ (Let’s call it 𝑀 ) 𝑃 𝑀 7 https://legacygl-js.glitch.me/demo/quaternion-schematic.html

  8. Decompose rotation into two reflections 1 st reflection : 2 nd reflection : 𝑕 ≔ βˆ’ sin $ % 𝑣 + cos $ βƒ— βƒ— % βƒ— 𝑀 𝑔 ≔ βƒ— 𝑀 Top view βƒ— πœ„ 𝑔 𝑕 βƒ— ' , 8 https://legacygl-js.glitch.me/demo/quaternion-schematic.html

  9. Combining two reflections 𝑔 23 = βˆ’ βƒ— 𝑔 23 βƒ— 𝑕 23 = 𝑔 23 βƒ— = 𝑆 ! βˆ’ βƒ— 𝑦 βƒ— 𝑕 βˆ’ βƒ— 𝑦 βƒ— 𝑕 βƒ— βƒ— 𝑕 23 β€’ Formula : 𝑆 ! 𝑆 βƒ— # βƒ— 𝑦 𝑔 βƒ— 𝑔 βƒ— βƒ— 𝑔 𝑦 βƒ— βƒ— 𝑕 ≔ βˆ’ sin ! " 𝑣 + cos ! β€’ Substitute 𝑔 ≔ βƒ— 𝑀, " βƒ— 𝑀 to the above 𝑕 βƒ— β€’ For the left part βƒ— 𝑔 : (because 𝑣 β‹… βƒ— 𝑀 = 0 ) 𝑀 # cos ! 𝑕 β‹… βƒ— βƒ— 𝑔 = βˆ’ sin ! " 𝑣 + cos ! " βƒ— 𝑀 β‹… βƒ— 𝑀 = " 𝑀 = 𝑀 " πœ• ) (because 𝑣× βƒ— βˆ’π‘€ # sin ! 𝑕× βƒ— βƒ— 𝑔 = βˆ’ sin ! " 𝑣 + cos ! " βƒ— 𝑀 Γ— βƒ— 𝑀 = " πœ• Therefore, βˆ’π‘€ % cos . 𝑕 βƒ— 𝑕 β‹… βƒ— 𝑕× βƒ— / + πœ• sin . βƒ— 𝑔 = βˆ’ βƒ— 𝑔 + βƒ— 𝑔 = / 𝑔 23 βƒ— 𝑕 23 = 0 1 𝑔 23 βƒ— 𝑕 23 = βˆ’π‘€ 2% cos . β€’ The right part βƒ— 23 is analogous : βƒ— / βˆ’ πœ• sin . / β€’ Finally, we get the formula : = βˆ’π‘€ ' cos ! βˆ’π‘€ (' cos ! " + πœ• sin ! " βˆ’ πœ• sin ! 𝑆 !, # βƒ— 𝑦 = 𝑆 $ 𝑆 βƒ— & βƒ— 𝑦 𝑦 βƒ— " " cos ! " + πœ• sin ! 𝑦 cos ! " βˆ’ πœ• sin ! = βƒ— " " 9

  10. Representing and blending poses using quaternions ℝ # β€’ Any rotations (poses) can be π‘Ÿ π‘ž = cos ! " + πœ• sin ! represented as unit quaternions " β€’ Points on hypersphere of 4D space β€’ Fix πœ• and vary πœ„ βˆ’π‘Ÿ Γ¨ unit circle in 4D space πœ„ =0 (1, 0,0,0) β€’ A pose after rotating 360 Β° about a certain axis is represented as another quaternion πœ„ = 𝜌 πœ„ =3 𝜌 (0, πœ• % , πœ• & , πœ• ' ) (0, - πœ• % ,- πœ• & ,- πœ• ' ) β€’ One pose corresponds to two quaternions (double cover) πœ„ =2 𝜌 β€’ A geodesic between two points π‘ž, π‘Ÿ on the (-1, 0,0,0) hypersphere represents interpolation of these poses β€’ Should pick either π‘Ÿ or βˆ’π‘Ÿ which is closer to π‘ž (i.e. 4D dot product is positive) 10

  11. Normalize quaternions or not? β€’ Any quaternions can be written as scaling of unit quaternions " , π‘Ÿ () = 𝑠 () cos ! π‘Ÿ = 𝑠 cos ! " + πœ• sin ! " βˆ’ πœ• sin ! " β€’ In the rotation formula, the scaling part is cancelled 𝑦 π‘Ÿ () = 𝑠 cos ! 𝑦 𝑠 () cos ! " + πœ• sin ! " βˆ’ πœ• sin ! = cos ! " + πœ• sin ! 𝑦 cos ! " βˆ’ πœ• sin ! π‘Ÿ βƒ— βƒ— βƒ— " " " " π‘Ÿ " Γ¨ so, normalization isn’t needed? β€’ In practice, don’t use quaternion mults for computing coordinate transformation (because inefficient) β€’ Just do explicit vector calc using axis & angle ) ! *) " 𝑦 βˆ’ πœ• β‹… βƒ— βƒ— 𝑦 πœ• cos πœ„ + πœ•Γ— βƒ— 𝑦 sin πœ„ + πœ• β‹… βƒ— 𝑦 πœ• " 𝑠 = 1 β€’ Can get axis & angle only after normalization β€’ Un-normalized can cause artifact when interpolated π‘Ÿ ( 11

  12. Modeling curves 12

  13. Parametric curves β€’ X & Y coordinates defined by parameter t ( β‰… time) β€’ Example: Cycloid 𝑦 𝑒 = 𝑒 βˆ’ sin 𝑒 𝑧 𝑒 = 1 βˆ’ cos 𝑒 β€’ Tangent (aka. derivative, gradient) vector: 𝑦 < 𝑒 , 𝑧 < 𝑒 β€’ Polynomial curve: 𝑦 𝑒 = βˆ‘ = 𝑏 = 𝑒 = 13

  14. Cubic Hermite curves x 𝑦 0 = 𝑦 @ β€’ Cubic polynomial curve interpolating 𝑦 1 = 𝑦 3 B derivative constraints at both ends 𝑦′(0) = 𝑦 @ 𝑦 B 1 = 𝑦 3 B (Hermite interpolation) 0 1 t 𝑦 0 = 𝑏 @ = 𝑦 @ β€’ 4 constraints Γ¨ 4 DoF needed 𝑦 1 = 𝑏 @ + 𝑏 3 + 𝑏 % + 𝑏 A = 𝑦 3 Γ¨ 4 coefficients Γ¨ cubic 𝑦 B 0 = 𝑏 3 B = 𝑦 @ β€’ 𝑦 𝑒 = 𝑏 @ + 𝑏 3 𝑒 + 𝑏 % 𝑒 % + 𝑏 A 𝑒 A 𝑦 B 1 = 𝑏 3 + 2 𝑏 % + 3 𝑏 A B = 𝑦 3 β€’ 𝑦′ 𝑒 = 𝑏 3 + 2𝑏 % 𝑒 + 3𝑏 A 𝑒 % Γ¨ 𝑏 @ = 𝑦 @ B β€’ Coeffs determined by substituting 𝑏 3 = 𝑦 @ B βˆ’ 𝑦 3 B constrained values & derivatives 𝑏 % = βˆ’3 𝑦 @ + 3 𝑦 3 βˆ’ 2 𝑦 @ B + 𝑦 3 B 𝑏 A = 2 𝑦 @ βˆ’ 2 𝑦 3 + 𝑦 @ 14

  15. Bezier curves 𝑄 β€’ Input: 3 control points (CPs) 𝑄 > , 𝑄 $ , 𝑄 , 3 β€’ Coordinates of points in arbitrary domain (2D, 3D, ...) 𝑄 𝑒 = ? 𝑄 % Eq. of Bezier curve β€’ Output: Curve 𝑄 𝑒 satisfying t=1 𝑄 0 = 𝑄 > 𝑄 @ 𝑄 𝑒 = 1 βˆ’ 𝑒 𝑄 @ + 𝑒 𝑄 % 𝑄 1 = 𝑄 , t=0 Eq. of line segment while being β€œpulled” by 𝑄 $ 15

  16. 𝑄 3 Bezier curves Eq. of line 𝑒 𝑄 3% 𝑒 1 βˆ’ 𝑒 1 βˆ’ 𝑒 Eq. of line β€’ 𝑄 @3 𝑒 = 1 βˆ’ 𝑒 𝑄 @ + 𝑒 𝑄 𝑄 @3 𝑒 𝑒 1 βˆ’ 𝑒 3 𝑄 @3% 𝑒 β€’ 𝑄 3% 𝑒 = 1 βˆ’ 𝑒 𝑄 3 + 𝑒 𝑄 % 𝑄 % β€’ 𝑄 *) 0 = 𝑄 * 𝑒 β€’ 𝑄 )' 1 = 𝑄 ' 𝑄 @ β€’ Idea: ”Interpolate the interpolation” As 𝑒 changes 0 β†’ 1 , smoothly transition from 𝑄 @3 to 𝑄 3% β€’ 𝑄 @3% 𝑒 = 1 βˆ’ 𝑒 𝑄 @3 𝑒 + 𝑒 𝑄 3% 𝑒 = 1 βˆ’ 𝑒 1 βˆ’ 𝑒 𝑄 @ + 𝑒 𝑄 3 + 𝑒 1 βˆ’ 𝑒 𝑄 3 + 𝑒 𝑄 % = 1 βˆ’ 𝑒 % 𝑄 @ + 2𝑒 1 βˆ’ 𝑒 𝑄 3 + 𝑒 % 𝑄 % Quadratic Bezier curve 16

  17. 𝑄 3 Bezier curves β€’ 𝑄 @3 𝑒 = 1 βˆ’ 𝑒 𝑄 @ + 𝑒 𝑄 3 β€’ 𝑄 3% 𝑒 = 1 βˆ’ 𝑒 𝑄 3 + 𝑒 𝑄 % 𝑄 % β€’ 𝑄 *) 0 = 𝑄 * β€’ 𝑄 )' 1 = 𝑄 ' 𝑄 @ β€’ Idea: ”Interpolate the interpolation” As 𝑒 changes 0 β†’ 1 , smoothly transition from 𝑄 @3 to 𝑄 3% β€’ 𝑄 @3% 𝑒 = 1 βˆ’ 𝑒 𝑄 @3 𝑒 + 𝑒 𝑄 3% 𝑒 = 1 βˆ’ 𝑒 1 βˆ’ 𝑒 𝑄 @ + 𝑒 𝑄 3 + 𝑒 1 βˆ’ 𝑒 𝑄 3 + 𝑒 𝑄 % = 1 βˆ’ 𝑒 % 𝑄 @ + 2𝑒 1 βˆ’ 𝑒 𝑄 3 + 𝑒 % 𝑄 % Quadratic Bezier curve 17

  18. Cubic Bezier curve Quad. Bezier 𝑄 3%A 𝑒 𝑄 % 𝑄 3 β€’ Exact same idea applied to 4 points 𝑄 @ , 𝑄 3 , 𝑄 % 𝑄 A : Quad. Bezier 1 βˆ’ 𝑒 𝑄 @3% 𝑒 β€’ As 𝑒 changes 0 β†’ 1 , transition from 𝑄 *)' to 𝑄 𝑄 @3%A 𝑒 )'+ 𝑄 A 𝑒 𝑄 @ β€’ 𝑄 @3%A 𝑒 = 1 βˆ’ 𝑒 𝑄 @3% 𝑒 + 𝑒 𝑄 3%A 𝑒 = 1 βˆ’ 𝑒 1 βˆ’ 𝑒 ' 𝑄 * + 2𝑒 1 βˆ’ 𝑒 𝑄 ) + 𝑒 ' 𝑄 ' + 𝑒 1 βˆ’ 𝑒 ' 𝑄 ) + 2𝑒 1 βˆ’ 𝑒 𝑄 ' + 𝑒 ' 𝑄 + 3 + 3𝑒 % 1 βˆ’ 𝑒 𝑄 % + 𝑒 A 𝑄 A = 1 βˆ’ 𝑒 A 𝑄 @ + 3𝑒 1 βˆ’ 𝑒 % 𝑄 Cubic Bezier curve 18

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