Download presentation

Presentation is loading. Please wait.

Published byTimothy Smith Modified over 4 years ago

1
Coordinate Spaces and Transformations Jihoon.Yim 22/04/2008

2
2 Contents Transformation of Coordinate Spaces World-space to Page-space Transformations Page-space to Device-space Transformations Device-Space to Physical-Device Transformation Default Transformations Using Coordinate Spaces and Transformations

3
3 Transformation of Coordinate Spaces Cartesian coordinate system Four coordinate spaces the system supports : Coordinate spaceDescription WorldUsed optionally as the starting coordinate space for graphics transformations. It allows scaling, translation, rotation, shearing, and reflection. 2^32 units high by 2^32 units wide. PageUsed either as the next space after world space or as the starting space for graphics transformations. It sets the mapping mode. 2^32 units high by 2^32 units wide DeviceIt only allows translation, which ensures the origin of the device space maps to the proper location in physical device space. 2^27 units high by 2^27 units wide. Physical deviceThe final space for graphics transformations. Terms Cartesian coordinate system : Coordinate space : scaling : translation : rotation : shearing :, reflection : origin :

4
4 Transformation of Coordinate Spaces To depict output on a physical device : –The system copies (or maps) a rectangular region from one coordinate space into the next using a transformation until the output appears in its entirety on the physical device. –Mapping begins in the applications world space if the application has called the SetWorldTransform function; –Otherwise, mapping occurs in page space. –As the system copies each point within the rectangular region from one space into another, it applies an algorithm called a transformation. Terms depict :, entirety :

5
5 World-space to Page-space Transformations World-space to page-space transformations support translation and scaling. In addition, they support rotation, shear, and reflection capabilities. Following topics will be shown in this section : Translation Scaling Rotation Shear Reflection

6
6 World-space to Page-space Transformations Translation –By calling the SetWorldTransform function –The SetWorldTransform function receives a pointer to an XFORM structure containing the appropriate values. –The eDx and eDy member of XFORM specify the horizontal and vertical translation components, respectively. Ex) a 20- by 20-unit rectangle that was translated to the right by 10 |1 0 0| |x` y` 1| = |x y 1| *|0 1 0| |Dx Dy 1| x` = x + Dx y` = y + Dy |1 0 0| |10 10| *|0 1 0| = (20, 10) |10 0 1| Terms respectively :

7
7 World-space to Page-space Transformations Scaling –By calling the SetWorldTransform function –The eM11 and eM22 members of XFORM specify the horizontal and vertical scaling components, respectively. Ex) a 20- by 20-unit rectangle scaled vertically to twice its original height: x` = x * Dx y` = y + Dy |x` y`| = |x y|*|Dx 0| |0 Dy| |10 5| = |10 5| *|1 0| = (10, 10) |0 2|

8
8 World-space to Page-space Transformations Rotation –By calling the SetWorldTransform function –The eM11, eM12, eM21, and eM22 members of XFORM specify respectively, the cosine, sine, negative sine, and cosine of the angle of rotation Ex) a 20- by 20-unit rectangle rotated 30 degrees : x` = (x * cos A) – (y * sin A) y` = (x * sin A) + (y * con A) |x` y`| == |x y| *| cos A sin A| |-sin A cos A| Terms angle :

9
9 World-space to Page-space Transformations Rotation Algorithm Derivation –Trigonometrys addition –Derivation x = h * cosA1 y = h * sinA1 x` = h * cos(A1 + A2) y` = h * sin(A1 + A2) x` = (h * cosA1 * cosA2) – (h * sinA1 * sinA2) y` = (h * cosA1 * sinA2) + (h * sinA1 * cosA2) x` = (x * cosA2) – (y * sinA2) y` = (x * sinA2) + (y * cosA2) sin(A1 + A2) = (sinA1 * cosA2) + (cosA1 * sinA2) cos(A1 + A2) = (cosA1 * cosA2) – (sinA1 * sinA2) Terms derivation : Trigonometrys addition :

10
10 World-space to Page-space Transformations Shear –By calling the SetWorldTransform function –The eM12 and eM21 members of XFORM specify the horizontal and vertical proportionality constants, Ex) a 20- by 20-unit rectangle sheared horizontally x` = x + (Sx * y) y` = y + (Sy * x) |x` y`| == |x y| *|1 Sy| |Sx 1| |20 5| *|1 0| = (25, 5) |1 1| Terms proportionality :

11
11 World-space to Page-space Transformations Reflection –By calling the SetWorldTransform function –The eM11 and eM22 members of XFORM specify the horizontal and vertical reflection components, respectively. –The reflection transformation creates a mirror image of an object with respect to either the x- or y-axis. –In short, reflection is just negative scaling. –To produce a horizontal reflection, x-coordinates are multiplied by -1. –To produce a vertical reflection, y-coordinates are multiplied by -1. |-1 0| The 2-by-2 matrix that produced horizontal reflection |0 1| |1 0| The 2-by-2 matrix that produced vertical reflection |0 -1|

12
12 World-space to Page-space Transformations Combined World-to-page Space Transformations –The five world-to-page transformations can be combined into a single 3-by-3 matrix. –CombineTransform function Can be used to combine two world-space to page-space transformations. –When an application calls SetWorldTransform, it stores the elements of the 3- by-3 matrix in an XFORM structure. The members of this structure correspond to the first two columns of a 3-by-3 matrix; The last column of the matrix is not required because it values are constant. | x11 x12 0| | x21 x22 0| | eDx eDy 1| –GetWorldTransform function to revive the elements of the current world transformation. typedef struct _XFROM { FLOAT eM11; FLOAT eM12; FLOAT eM21; FLOAT eM22; FLOAT eDx; FLOAT eDy; } XFORM, *PXFORM;

13
13 Page-space to Device-space Transformations The page-space to device-space transformation determines the mapping mode for all graphic output associated with a particular DC. A mapping mode is a scaling transformation. Following topics will be shown in this section : Mapping Modes and Translations Predefined Mapping Modes Application-Defined Mapping Modes

14
14 Page-space to Device-space Transformations Mapping Modes and Translations Mapping ModeUnitAxesDevice IndependentCoordinate MM_ANISOTROPICApp-specificAnyThe axis may or may not be equally scaled. App-specific MM_ISOTROPICApp-specificMust Equal The axis are always equally scaled. App-specific MM_HIENGLISH0.001 inchFixedIndependent MM_LOENGLISH0.01 inchFixedIndependent MM_HIMETRIC0,01 millimeterFixedIndependent MM_LOMETRIC0.1 millimeterFixedIndependent MM_TWIPS1/12 of a printer point (1/1440 inch) FixedIndependent MM_TEXT (Default)One pixelFixedDependent Terms Unit : Axis : Anisotropic : Isotropic :

15
15 Page-space to Device-space Transformations SetMapMode & GetMapMode –To set a mapping mode and To retrieve the current mapping mode for a DC Window & Viewport –The page space to device-space transformations consist of values calculated from the points given by the window and viewport. –Window the logical coordinate system of the page space –Viewport the device coordinate system of the device space (pixel) –The window and viewport each consist of an origin, a horizontal (x) extent, and a vertical (y) extent. –The system combines the origins and extents from both the window and viewport to create the transformation. Terms origin : extent :,

16
16 Page-space to Device-space Transformations Maps the window to the viewport –The window and viewport extents establish a ratio or scaling factor used in the page-space to device-space transformations.

17
17 Page-space to Device-space Transformations Maps the window to the viewport Predefined mapping modes –MM_HIENGLISH, MM_LOENGLISH, MM_HIMETRIC, MM_LOMETRIC, MM_TEXT, and MM_TWIPS –the extents are set by the system when SetMapMode is called. –They cannot be changed. The other two mapping modes –MM_ISOTROPIC, MM_ANISOTROPIC –the extents must be specified. –After calling SetMapMode, call the SetWindowExtEx and SetViewportExtEx functions to specify the extents. –In the MM_ISOTROPIC mapping mode, its important to call SetWindowExtEx before calling SetViewportExtEx.

18
18 Page-space to Device-space Transformations Maps the window to the viewport –The window and viewport origins establish the translation used in the page-space to device-space transformations. –Set the window and viewport origins by using the SetWindowOrgEx and SetViewportOrgEx functions. –The origins are independent of the extents, and an application can set them regardless of the current mapping mode. –Changing a mapping mode does not affect the currently set origins (although it can affect the extents). –Origins are specified in absolute units that the current mapping mode does not affect. –To alter the origins, use the OffsetWindowOrgEx and OffsetViewportOrgEx functions. Terms regardless of : ~ affect :

19
19 Page-space to Device-space Transformations Maps the window to the viewport –The following formula shows the math involved in converting a point from page space to device space. Dx : x value in device units Lx : x value in logical units (also known as page space units) WOx : window x origin VOx : viewport x origin WEx : window x-extent VEx : viewport x-extent –The same equation with y replacing x transforms the y component of a point. –The LPtoDP and DPtoLP functions may be used to convert from logical points to device points and from device points to logical points, respectively. Dx = ((Lx – WOx) * VEx / WEx) + VOx) Terms formula : equation :

20
20 Page-space to Device-space Transformations Predefined Mapping Modes –Device dependent MM_TEXT –Device independent MM_HIENGLISH, MM_LOENGLISH, MM_HIMETRIC, MM_LOMETRIC, and MM_TWIPS –The default mapping mode is MM_TEXT One logical unit equals one pixel. Positive x is to the right, and positive y is down. This mode maps directly to the devices coordinate system. The logical-to-physical mapping involves only an offset in x and y that is defined by the application-controlled window and viewport origins. The viewport and window extents are all set to 1, creating a one-to-one mapping. –Applications that display geometric shapes make use of one of the device- independent mapping modes. Terms geometric :

21
21 Page-space to Device-space Transformations Application-Defined Mapping Modes –MM_ISOTROPIC and MM_ANISOTROPIC) are provided for application-specific mapping modes. MM_ISOTROPIC guarantees that logical units in the x-direction and in the y-direction are equal MM_ANISOTROPIC mode allows the units to differ. –a CAD or drawing application can benefit from the MM_SIOTROPIC mapping mode (or MM_ANISOTROIPIC) may need to specify logical units that correspond to the increments on an engineers scale(1/64 inch) These units would be difficult to obtain with the predefined mapping modes. –The following examples shows how to set logical units to 1/64 inch : SetMapMode(hDC, MM_ISOTROPIC); SetWindowExtEx(hDC, 64, 64, NULL); SetViewportExtEx(hDC, GetDeviceCaps(hDC, LOGPIXELSX), GetDevcieCaps(hDC, LOGPIXELSY), NULL);

22
22 Device-Space to Physical-Device Transformation Unique in several respects –It is limited to translation and is controlled by the system. –The sole purpose of this transformation is to ensure that the origin of device space is mapped to the proper point on the physical device. –There are no functions to set this transformation, nor are there any functions to retrieve related data.

23
23 Default Transformations Default transformations –Whenever an application creates a DC and immediately begins calling GDI drawing or output functions, it takes advantage of the default page-space to device-space, and device-space to client-area transformations. –A world-to-page space transformation cannot happen until the application first calls the SetGraphicsMode function to set the mode to GM_ADVANCED and then calls the SetWorldTransform function. –Use of MM_TEXT (the default page-space to device space transformation) results in a one-to-one mapping; That is, a given point in page space maps to the same point in device space. –The one unique aspect of MM_TEXT is the orientation of the y-axis in page space. In MM_TEXT, the positive y-axis extends downward and the negative y- axis extends upward.

24
24 Using Coordinate Spaces and Transformations The example contains the following tasks: –Drawing graphics with predefined units. –Centering graphics in the applications client area –Scaling graphics output to half its original size. –Translating graphics output ¾ of an inch to the right. –Rotating graphics 30 degrees. –Shearing graphics output along the x-axis. –Reflecting graphics output about an imaginary horizontal axis drawn through its midpoint.

25
25 References MSDN 2003

Similar presentations

Presentation is loading. Please wait....

OK

Computer Vision Lecture 7: The Fourier Transform

Computer Vision Lecture 7: The Fourier Transform

© 2018 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google

Ppt on role of individual in conservation of natural resources Ppt on cost leadership strategy Ppt on customer based brand equity Ppt on gulliver's travels part 4 Presentation ppt on android Ppt on space explorations Ppt on orphans in india Doc convert to ppt online Ppt on struts framework in java Ppt on object-oriented programming definition