Anisotropic and Isotropic mapping modes for Polygon Triangulation
By : Omer Guinko
Published Date : February 03, 2009
Page    [First/Prev] 1, 2, 3, 4, 5, 6, 7 [Next/Last]

Logical Coordinates
As  below figure shows, the origin of the device-coordinates system lies at the top-left corner of the canvas, so that the positive y-axis points downward. However this direction of the y-axis is different from normal mathematical practice and therefore often inconvenient to graphics applications.

Fortunately, we can arrange for the positive y-direction to be reversed by performing this simple transformation:

 yprime
logical-sys

Continuous vs. Discrete coordinates
Instead of the discrete (integer) coordinates we are using at the lower, device oriented level, we want to use continuous (floating-point) coordinates at the higher, problem oriented level. Other usual terms are device and logical coordinates, respectively.

We are two solutions to this problem in which increasing a logical coordinate by one results in increasing the device coordinate also by one. Restricting ourselves to x-coordinates, suppose we want to write the following methods:

iX(x) to convert a value of x of type float to a value of X of type int
fx(X) to convert a value X of type int to a value x of type float

The first solution is based on rounding:

int iX(float x){return Math.round(x);}
float fx(int X){return (float)X;}

for example with this solution we have iX(3.7) = 4 and fx(4) = 4.0


The second solution is based on truncating:

int iX(float x){return (int)x;}
float fx(int X){return (float)X + 0.5F;}

With these conversion functions we will have iX(3.7) = 3 and fx(4) = 4.5

Besides the above methods iX and fx (based of the first solution) for x-coordinates, we need similar methods for y-coordinates, taking into account the opposite direction of the two y-axes.

int iX(float x){return Math.round(x);}
int iY(float y){return maxY - Math.round(y);}
float fx(int X){return (float)X;}
float fy(int Y){return (float)(maxY - Y);}

 

Page    [First/Prev] 1, 2, 3, 4, 5, 6, 7 [Next/Last]