Coordinate Systems and Trasformations

Coordinate Systems [6.4]

Geometric coordinates are specified in the user coordinate system. The path-user-tosurface (VG_MATRIX_PATH_USER_TO_SURFACE) and image-user-to-surface (VG_MATRIX_IMAGE_USER_TO_SURFACE) transformations map between the user coordinate system and pixel coordinates on the destination drawing surface.
This pixel-based coordinate system is known as the surface coordinate system.
The user coordinate system is oriented such that values along the x-axis increase from left to right and values along the y-axis increase from bottom to top.
In the surface coordinate system, pixel (0, 0) is located at the lower-left corner of the drawing surface.

Matrix Transformation [6.6]

Select Matrix Mode

The current matrix to be manipulated is specified by setting the matrix mode. Separate matrices are maintained for transforming paths, images, and paint (gradients and patterns). The matrix modes are defined in the VGMatrixMode enumeration:

Matrix modeType of matrix

To set the matrix mode, call vgSeti with a type of VG_MATRIX_MODE and a value of VGMatrixMode.
For example, to set the matrix mode to allow manipulation of the path-user-to-surface transformation, call:


Matrix Manipulation API

The matrix conventions used by OpenVG are similar to those of OpenGL. A point to be transformed is given by a homogeneous column vector . Transformation of a point by a matrix is defined as the product . Concatenation of transformations is performed using right-multiplication of matrices.

$$ M = \begin{bmatrix} sx & shx & tx \\ shy & sy & ty \\ w_0 & w_1 & w_2 \end{bmatrix} \qquad p = \begin{bmatrix} x \\ y \\ 1 \end{bmatrix} $$

Matrix m = { sx, shy, w0, shx, sy, w1, tx, ty, w2 }
For affine transformations, w0 = w1 = 0, w2 = 1

void vgLoadIdentity(void)
void vgLoadMatrix(const VGfloat* m)
void vgMultMatrix(const VGfloat* m)
void vgGetMatrix(VGfloat* m)
void vgTranslate(VGfloat tx, VGfloat ty)
void vgScale(VGfloat sx, VGfloat sy)
void vgShear(VGfloat shx, VGfloat shy)
void vgRotate(VGfloat angle)