1. Trang chủ
  2. » Công Nghệ Thông Tin

geometry in matlab slide

41 183 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 41
Dung lượng 255 KB

Nội dung

Geometry (Many slides adapted from Octavia Camps and Amitabh Varshney) Goals • Represent points, lines and triangles as column vectors. • Represent motion as matrices. • Move geometric objects with matrix multiplication. • Refresh memory about geometry and linear algebra Vectors • Ordered set of numbers: (1,2,3,4) • Example: (x,y,z) coordinates of pt in space. runit vecto a is ,1 If ),( 1 2 ,, 21 vv xv xxxv n i i n = = = ∑ =  Vector Addition ),(),(),( 22112121 yxyxyyxx ++=+=+ wv v v w w V+w V+w Scalar Product ),(),( 2121 axaxxxaa == v v v av av Inner (dot) Product v v w w α α 22112121 .),).(,(. yxyxyyxxwv +== The inner product is a The inner product is a SCALAR! SCALAR! α cos||||||||),).(,(. 2121 wvyyxxwv ⋅== wvwv ⊥⇔= 0. Points Using these facts, we can represent points. Note: (x,y,z) = x(1,0,0) + y(0,1,0) + z(0,0,1) x = (x,y,z).(1,0,0) y = (x,y,z).(0,1,0) z = (x,y,z).(0,0,1) Lines • Line: y = mx + a • Line: sum of a point and a vector P = P 1 + αd (whered is a column vector) • Line: Affine sum of two points P = α 1 P 1 + α 2 P 2 , where α 1 + α 2 = 1 Line Segment: For 0 ≤ α 1 , α 2 ≤ 1, P lies between P 1 and P 2 • Line: set of points equidistant from the origin in the direction of a unit vector. P 1 d P 1 P 2 Plane and Triangle • Plane: sum of a point and two vectors P = P 1 + αu + β v Plane: set of points equidistant from origin in direction of a vector. • Triangle: Affine sum of three points with α i ≥ 0 P = α 1 P 1 + α 2 P 2 + α 3 P 3 , where α 1 + α 2 + α 3 = 1 P lies between P 1 , P 2 , P 3 P 1 u v P 1 P 2 P 3 Generalizing Affine Sum of arbitrary number of points: Convex Hull P = α 1 P 1 + α 2 P 2 + … + α n P n , where α 1 + α 2 + … + α n = 1 and α i ≥ 0 [...]... c d     sin θ = − cosθ  sin θ = sy  − cosθ SVD cosθ   s x  0 sin θ    sx cosθ    sy sin θ  0  0  sin ϕ  s y − cos ϕ  0  sin ϕ ⋅  − cos ϕ 1  cos ϕ   x   ⋅  y sin ϕ    cos ϕ   x  sin ϕ   y    Affine Transformation  x a b tx    P' →  ⋅  y   c d ty   1    Viewing Position • Express world in new coordinate system • If origins same, this... coefficients of x, y, z in a plane equation define the normal Normal of a Triangle Normal of the plane containing the triangle (P1, P2 , P3 ): n P3 n = (P2 - P1) × (P3 - P1) P3 P2 Normal pointing towards you P1 P1 P2 Normal pointing away from you P2 P1 P3 • Models constructed with consistent ordering of triangle vertices : − all clockwise or all counter-clockwise • Usually normals point out of the model... satisfy the following constraints: R ⋅ RT = RT ⋅ R = I det(R ) = 1 Transformations can be composed • Matrix multiplication is associative • Combine series of transformations into one matrix (example, whiteboard) • In general, the order matters (example, whiteboard) • 2D Rotations can be interchanged Why? Rotation and Translation ( cos θ -sin θ tx sin θ cos θ ty 0 0 )( ) x y 1 1 Rotation, Scaling and Translation...  P Scaling P’ P Scaling Equation P’ s.y P P = ( x, y ) P ' = ( sx, sy ) P' = s ⋅ P y x s.x  sx   s 0  x  P' →   =  ⋅  y   sy  0 s    P' = S ⋅ P S Rotation P P’ Rotation Equations Counter-clockwise rotation by an angle θ Y’ P’ θ P y X’ x  x' cos θ  y ' =  sin θ    P' = R.P − sin θ   x  cosθ   y    Degrees of Freedom  x' cosθ  y ' =  sin θ    − sin θ  ... Rotation about an arbitrary point • Can translate to origin, rotate, translate back (example, whiteboard) • This is also rotation with one translation – Intuitively, amount of rotation is same either way – But a translation is added Stretching Equation P = ( x, y ) P ' = ( s x x, s y y ) P’ Sy.y  sx x  sx P' →   =  sy y  0  P y x 0   x ⋅   sy   y S Sx.x P' = S ⋅ P Linear Transformation a... counter-clockwise • Usually normals point out of the model Normal of a Vertex in a Mesh nv = (n1 +n2 + … +nk) / k = ∑ni / k = average of adjacent triangle normals ∀nv ∀nk or better: nv = ∑ (Αi ni) / (k ∑ (Αi) ) = area-weighted average of adjacent triangle normals ∀n ∀n1 3 ∀n2 Geometry Continued • Much of last classes’ material in Appendix A Matrices An×m  a11 a  21 = a31    an1  a12 a22...  y    Affine Transformation  x a b tx    P' →  ⋅  y   c d ty   1    Viewing Position • Express world in new coordinate system • If origins same, this is done by taking inner product with new coordinates • Otherwise, we must translate ... Matrices Determinant: A must be square  a11 det  a21 a12  a11 = a a22  21  a11 det a21  a31  a12 a22 a32 a12 = a11a22 − a21a12 a22 a13   = a a22 a23  11 a32 a33   a23 a21 − a12 a33 a31 a23 a21 + a13 a33 a31 a22 a32 Euclidean transformations 2D Translation P’ t P 2D Translation Equation ty P P’ t y x P = ( x, y ) t = (t x , t y ) tx P ' = ( x + t x , y + t y ) = P+t 2D Translation using Matrices...Normal of a Plane Plane: sum of a point and two vectors P = P1 + αu + βv v P - P1 = αu + βv P1 Ifn is orthogonal tou andv (n =u T T u ×v ) : T n • (P - P1) = αn •u + βn •v = 0 n v P1 u Implicit Equation of a Plane T n . P 3 P 1 P 2 P 3 P 1 P 3 P 2 Normal pointing towards you Normal pointing away from you • Models constructed with consistent ordering of triangle vertices : − all clockwise or all counter-clockwise. • Usually normals point. + a • Line: sum of a point and a vector P = P 1 + αd (whered is a column vector) • Line: Affine sum of two points P = α 1 P 1 + α 2 P 2 , where α 1 + α 2 = 1 Line Segment: For 0 ≤ α 1 ,. between P 1 and P 2 • Line: set of points equidistant from the origin in the direction of a unit vector. P 1 d P 1 P 2 Plane and Triangle • Plane: sum of a point and two vectors P = P 1

Ngày đăng: 24/10/2014, 23:36

TỪ KHÓA LIÊN QUAN