Bài giảng môn Đồ họa và hiện thực ảo - Bài 4: Các phép biến đổi đồ hoạ - Transformations
Số trang: 16
Loại file: pdf
Dung lượng: 907.19 KB
Lượt xem: 14
Lượt tải: 0
Xem trước 2 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Bài 4 - Các phép biến đổi đồ hoạ Transformations. Bài giảng trình bày một số nội dung như: Phép biến đổi transformations, phép biến đổi affine affine transformations, modeling transformations, biểu diễn ma trận, matrix representation, các phép biến đổi hình học hai chiều,... Mời các bạn cùng tham khảo.
Nội dung trích xuất từ tài liệu:
Bài giảng môn Đồ họa và hiện thực ảo - Bài 4: Các phép biến đổi đồ hoạ - Transformations Khoa CNTT - DDHBK Hà nội hunglt@it-hut.edu.vn 8682595 Phép biến đổi - Transformations Bài 4 Các phép biến đổi Đồ hoạ z Transformations z Trong kỹ thuật đồ hoạ 3 bước: Mô hình, Tô trát và Hiên thị (modeling, rendering, displaying) Với Modeling ( Mô hình hóa) : modeling coordinate Modeling transformation world coordinate Viewing transformation viewing coordinate (eye coordinate) Le Tan Hung Email: hunglt@it-hut.edu.vn z Transformation: là phép ánh xạ tọa độ điểm hay vector thành tọa độ hay vector khác 2 1 Transformations - Modeling Phép biến đổi Transformations z – z build complex models by positioning simple components Biến đổi tạo góc nhìn - Viewing transformations – – z world Biến đổi mô hình hoá - Modeling transformations placing virtual camera in the world transformation from world coordinates to camera coordinates Biến Phép chiếu – Projection Transform 3 4 Phép biến đổi Affine Affine Transformations? z Modeling Transformations Phép biến đổi Affine là phép biến đổi tọa độ Transform objects/points điểm đặc trưng của đối tượng thành tập tương ứng các điểm mới để tạo ra các hiệu ứng cho toàn đối tượng. – Ví dụ: phép biến đổi tọa độ với chỉ 2 điểm đầu cuối của Transform coordinate system đoạn thẳng tạo thành 2 điểm mới mà khi nối chúng với nhau tạo thành đoạn thẳng mới. z Các điểm nằm trên đoạn thẳng sẽ có kết quả là điểm nằm trên đoạn thẳng mới với cùng phép biến đổi thông qua phép nội suy. 5 6 1 Khoa CNTT - DDHBK Hà nội hunglt@it-hut.edu.vn 8682595 Biểu diễn Ma trận z z z Matrix Representation z Việc biến đối các đối tượng làm thay đổi các điểm P thành các điểm Q theo thuật toán Việc biến đổi P sử dụng tọa độ của P (Px,Py) ánh xạ thành các tọa độ mới Q (Qx,Qy) Việc biến đổi có thể biểu diễn thông qua hàm T, hàm ánh xạ của điểm: – – z T(Px,Py) = (Qx,Qy) or: T(P) = Q – – – Phép biến đổi đồ họa - affine transformation T ánh xạ tập P sang tập Q: – Qx = aPx + bPx + t x z Biểu diễn ma trận: i.e. ⎛Qx ⎜ ⎜Q ⎝ y ⎞ ⎛a ⎟ = ⎜⎜ ⎟ ⎠ ⎝c b d ⎞ ⎛ Px ⎞ ⎛ t x ⎟+⎜ ⎟⎟ ⎜⎜ ⎟ ⎜ ⎠⎝ Py ⎠ ⎝ t y ⎞ ⎟ ⎟ ⎠ Q = MP + Tr 7 8 Các phép biến đổi hình học hai chiều z z z Phương pháp biểu diễn đối tượng P = [ x Phép biến đổi vị trí điểm ⎡a b ⎤ Phép biến đổi y ] T =⎢ ⎥ ⎣c d ⎦ Thực thi phép biến đổi đúng trên 1 điểm ảnh sẽ đúng trên toàn bộ đối tượng a [X ]* [T ] = [x y ]* ⎡⎢ ⎣c [ b⎤ = [(ax + cy ) (bx + dy )] = x ' y ' d ⎥⎦ Phép bất biến z Phép biến đổi tỉ lệ - Scaling A scaling changes the size of an object with two scale factors, Sx and Sy z ] z z x z 9 x ⎡ a 0⎤ y ]* ⎢ ⎥ = [(ax ) y ] = [x' y '] ⎣0 1⎦ 1 b [X ]* [T ] = [x y ]* ⎡⎢ ⎤⎥ = [bx + dy ] = [x' y '] ⎣0 1 ⎦ [X ]* [T ] = [x pW pM ⎡1 0 ⎤ T =⎢ ⎥ ⎣0 1 ⎦ z y z y Phép biến dạng A shearing shears an object in a particular direction, (in 2D, it’s either in the x or in the y direction 10 Thuộc tính cơ bản của phép biến đổi Affine Transformations Phép quay- Rotation x = ρ cos α, y = ρ sin α ; x’ = ρ cos (θ +α ), y’ = ρ sin (θ +α ) ; x’ = ρ ( cosθ cosα - sinθ sinα ) = x cosθ - y sinθ y’ = ρ ( sinθ cosα + cosθ sinα ) = x sinθ + y cosθ [x' y']= [xcosθ - ysinθ xsinθ + ycosθ] z y ⎡ cos θ [T ] = ⎢ ⎣ − sin θ sin θ ⎤ cos θ ⎥⎦ Preservation of lines: – ( x’, y’ ) – ρ ( x, y ) – ρ θ 11 Q y = cPy + dPy + t y where a, b, c, d, tx and ty là các hệ số α x – 12 – They preserve lines, so the image of a straight line is another straight line. This vastly simplifies drawing transformed line segments. We need only compute the image of the two endpoints of the original line and then draw a straight line between them Preservation of collinearity guarantees that polygons will transform into polygons Affine transformations map lines to lines; 2 Khoa CNTT - DDHBK Hà nội hunglt@it-hut.edu.vn 8682595 Kết hợp các phép biến đổi Composition of Affine Transforms Thuộc tính z – z Preservation of parallelism guarantees that parallelograms will transform into parallelograms z Preservation of proportional distances – z z Preservation of parallelism Preservation of proportional distances means that midpoints of lines remain mid-points Affine transformations change volume by | Det(M) |; 13 Any affine transformation can be decomposed into elementary transformations. Mọi phép biến đổi phức tạp đều có thể tạo thành từ các phép biến đổi cơ sở như: – Dịch chuyển - Translation – Tỉ lệ - Scaling – Quay- Rotation – Biến dạng - Shearing 14 Affine transformations preserve affine combinations z z z z T It is rare that we want to perform just one elementary transformation. Usually an application requires that we build a complex transformation out of several elementary ones – z Thuộc tính z z These individual transformations combine into one overall transformation This is called the composition of transformations. The composition of two or more affine transformations is also an affine transformation 15 Tác động lên tập các điểm đặc trưng của đối tượng tạo thành phép biến đổi cho đối tượng e.g. translate an object, rotate it, and scale it, all in one move z We have defined each transformation by their effects on single points In practice these will be applied to multiple points to transfer entire scenes or objects made up of many defining points 16 Điểm gốc - Pivotal points Pivotal points Cho phép quay và tỉ lệ Rotation and Scaling z z z z z The simple versions of rotation and scaling have been based around the origin. This means that when we rotate or scale, the object will also move, with respect to the origin Translate all points through (-c1,-c2) Rotate all points about the origin by z z z z Translate all points back through (c1,c2) Often we wish to rotate or scale with respect to some pivotal point, not the origin Most significantly, we often wish to rotate or scale an object about its centre, or midpoint In this way, the object’s location does not change T ...
Nội dung trích xuất từ tài liệu:
Bài giảng môn Đồ họa và hiện thực ảo - Bài 4: Các phép biến đổi đồ hoạ - Transformations Khoa CNTT - DDHBK Hà nội hunglt@it-hut.edu.vn 8682595 Phép biến đổi - Transformations Bài 4 Các phép biến đổi Đồ hoạ z Transformations z Trong kỹ thuật đồ hoạ 3 bước: Mô hình, Tô trát và Hiên thị (modeling, rendering, displaying) Với Modeling ( Mô hình hóa) : modeling coordinate Modeling transformation world coordinate Viewing transformation viewing coordinate (eye coordinate) Le Tan Hung Email: hunglt@it-hut.edu.vn z Transformation: là phép ánh xạ tọa độ điểm hay vector thành tọa độ hay vector khác 2 1 Transformations - Modeling Phép biến đổi Transformations z – z build complex models by positioning simple components Biến đổi tạo góc nhìn - Viewing transformations – – z world Biến đổi mô hình hoá - Modeling transformations placing virtual camera in the world transformation from world coordinates to camera coordinates Biến Phép chiếu – Projection Transform 3 4 Phép biến đổi Affine Affine Transformations? z Modeling Transformations Phép biến đổi Affine là phép biến đổi tọa độ Transform objects/points điểm đặc trưng của đối tượng thành tập tương ứng các điểm mới để tạo ra các hiệu ứng cho toàn đối tượng. – Ví dụ: phép biến đổi tọa độ với chỉ 2 điểm đầu cuối của Transform coordinate system đoạn thẳng tạo thành 2 điểm mới mà khi nối chúng với nhau tạo thành đoạn thẳng mới. z Các điểm nằm trên đoạn thẳng sẽ có kết quả là điểm nằm trên đoạn thẳng mới với cùng phép biến đổi thông qua phép nội suy. 5 6 1 Khoa CNTT - DDHBK Hà nội hunglt@it-hut.edu.vn 8682595 Biểu diễn Ma trận z z z Matrix Representation z Việc biến đối các đối tượng làm thay đổi các điểm P thành các điểm Q theo thuật toán Việc biến đổi P sử dụng tọa độ của P (Px,Py) ánh xạ thành các tọa độ mới Q (Qx,Qy) Việc biến đổi có thể biểu diễn thông qua hàm T, hàm ánh xạ của điểm: – – z T(Px,Py) = (Qx,Qy) or: T(P) = Q – – – Phép biến đổi đồ họa - affine transformation T ánh xạ tập P sang tập Q: – Qx = aPx + bPx + t x z Biểu diễn ma trận: i.e. ⎛Qx ⎜ ⎜Q ⎝ y ⎞ ⎛a ⎟ = ⎜⎜ ⎟ ⎠ ⎝c b d ⎞ ⎛ Px ⎞ ⎛ t x ⎟+⎜ ⎟⎟ ⎜⎜ ⎟ ⎜ ⎠⎝ Py ⎠ ⎝ t y ⎞ ⎟ ⎟ ⎠ Q = MP + Tr 7 8 Các phép biến đổi hình học hai chiều z z z Phương pháp biểu diễn đối tượng P = [ x Phép biến đổi vị trí điểm ⎡a b ⎤ Phép biến đổi y ] T =⎢ ⎥ ⎣c d ⎦ Thực thi phép biến đổi đúng trên 1 điểm ảnh sẽ đúng trên toàn bộ đối tượng a [X ]* [T ] = [x y ]* ⎡⎢ ⎣c [ b⎤ = [(ax + cy ) (bx + dy )] = x ' y ' d ⎥⎦ Phép bất biến z Phép biến đổi tỉ lệ - Scaling A scaling changes the size of an object with two scale factors, Sx and Sy z ] z z x z 9 x ⎡ a 0⎤ y ]* ⎢ ⎥ = [(ax ) y ] = [x' y '] ⎣0 1⎦ 1 b [X ]* [T ] = [x y ]* ⎡⎢ ⎤⎥ = [bx + dy ] = [x' y '] ⎣0 1 ⎦ [X ]* [T ] = [x pW pM ⎡1 0 ⎤ T =⎢ ⎥ ⎣0 1 ⎦ z y z y Phép biến dạng A shearing shears an object in a particular direction, (in 2D, it’s either in the x or in the y direction 10 Thuộc tính cơ bản của phép biến đổi Affine Transformations Phép quay- Rotation x = ρ cos α, y = ρ sin α ; x’ = ρ cos (θ +α ), y’ = ρ sin (θ +α ) ; x’ = ρ ( cosθ cosα - sinθ sinα ) = x cosθ - y sinθ y’ = ρ ( sinθ cosα + cosθ sinα ) = x sinθ + y cosθ [x' y']= [xcosθ - ysinθ xsinθ + ycosθ] z y ⎡ cos θ [T ] = ⎢ ⎣ − sin θ sin θ ⎤ cos θ ⎥⎦ Preservation of lines: – ( x’, y’ ) – ρ ( x, y ) – ρ θ 11 Q y = cPy + dPy + t y where a, b, c, d, tx and ty là các hệ số α x – 12 – They preserve lines, so the image of a straight line is another straight line. This vastly simplifies drawing transformed line segments. We need only compute the image of the two endpoints of the original line and then draw a straight line between them Preservation of collinearity guarantees that polygons will transform into polygons Affine transformations map lines to lines; 2 Khoa CNTT - DDHBK Hà nội hunglt@it-hut.edu.vn 8682595 Kết hợp các phép biến đổi Composition of Affine Transforms Thuộc tính z – z Preservation of parallelism guarantees that parallelograms will transform into parallelograms z Preservation of proportional distances – z z Preservation of parallelism Preservation of proportional distances means that midpoints of lines remain mid-points Affine transformations change volume by | Det(M) |; 13 Any affine transformation can be decomposed into elementary transformations. Mọi phép biến đổi phức tạp đều có thể tạo thành từ các phép biến đổi cơ sở như: – Dịch chuyển - Translation – Tỉ lệ - Scaling – Quay- Rotation – Biến dạng - Shearing 14 Affine transformations preserve affine combinations z z z z T It is rare that we want to perform just one elementary transformation. Usually an application requires that we build a complex transformation out of several elementary ones – z Thuộc tính z z These individual transformations combine into one overall transformation This is called the composition of transformations. The composition of two or more affine transformations is also an affine transformation 15 Tác động lên tập các điểm đặc trưng của đối tượng tạo thành phép biến đổi cho đối tượng e.g. translate an object, rotate it, and scale it, all in one move z We have defined each transformation by their effects on single points In practice these will be applied to multiple points to transfer entire scenes or objects made up of many defining points 16 Điểm gốc - Pivotal points Pivotal points Cho phép quay và tỉ lệ Rotation and Scaling z z z z z The simple versions of rotation and scaling have been based around the origin. This means that when we rotate or scale, the object will also move, with respect to the origin Translate all points through (-c1,-c2) Rotate all points about the origin by z z z z Translate all points back through (c1,c2) Often we wish to rotate or scale with respect to some pivotal point, not the origin Most significantly, we often wish to rotate or scale an object about its centre, or midpoint In this way, the object’s location does not change T ...
Tìm kiếm theo từ khóa liên quan:
Đồ họa máy tính Hiện thực ảo Kỹ thuật đồ họa Computer Graphics Virtual Reality Phép biến đổi đồ hoạ Phép biến đổi đồ hoạ transformations Biểu diễn ma trậnGợi ý tài liệu liên quan:
-
66 trang 423 3 0
-
77 trang 306 3 0
-
vray for sketchup vietnamese PHẦN 3
10 trang 212 0 0 -
Giáo trình Autocad - Nghề: Quản trị mạng máy tính - Trình độ: Cao đẳng nghề (Phần 2)
52 trang 209 0 0 -
Đề cương chi tiết môn học Kỹ thuật đồ họa và xử lý ảnh
5 trang 175 1 0 -
Luận văn tốt nghiệp: Tìm hiểu về SIMULINK trong MATLAB
50 trang 155 0 0 -
Giáo trình CorelDRAW dành cho người mới học
48 trang 141 0 0 -
Giáo trình CorelDraw 10 - Tham khảo toàn diện: Phần 2
528 trang 133 0 0 -
Bài giảng Đồ họa máy tính: Khử mặt khuất - Ngô Quốc Việt
28 trang 127 0 0 -
Giáo trình Kỹ thuật đồ họa cho ngành Đa phương tiện: Phần 1
106 trang 87 1 0