GLG Toolkit, C / C++ API Library  Version 4.6
Coordinate Conversion

This group contains methods for converting coordinate values between the screen and GLG world coordinate systems. More...

Detailed Description

This group contains methods for converting coordinate values between the screen and GLG world coordinate systems.

It also contains methods for handling Matrix objects used by the Toolkit to perform geometrical transformations.

Functions

GlgObject GetDrawingMatrix (void)
 Returns the transformation matrix used to draw the object. More...
 
void GetMatrixData (GlgMatrixData *matrix_data)
 Queries coefficients of this matrix. More...
 
GlgObject InverseMatrix (void)
 Inverts this matrix object. More...
 
GlgBoolean ScreenToWorld (GlgBoolean inside_vp, GlgPoint *in_point, GlgPoint *out_point)
 Converts a point's screen coordinates to the GLG world coordinate system. More...
 
void SetMatrixData (GlgMatrixData *matrix_data)
 Sets coefficients of this matrix. More...
 
void TransformPoint (GlgPoint *in_point, GlgPoint *out_point)
 Transforms a single point using this matrix. More...
 
GlgBoolean WorldToScreen (GlgBoolean inside_vp, GlgPoint *in_point, GlgPoint *out_point)
 Converts a point's coordinates from the GLG world coordinate system to the screen coordinate system. More...
 

Function Documentation

◆ GetDrawingMatrix()

GlgObject GetDrawingMatrix ( void  )

Returns the transformation matrix used to draw the object.

This is a wrapper for GlgGetDrawingMatrix.

Returns
A matrix object that combines matrices of all transformations used to draw this object.

Transformation matrices are only used for geometric transformations, so this method may be called only for graphical objects, like polygons, arcs and text objects. This method must be called after the object has been drawn. (That is, after its hierarchy has been set up.)

The method returns the internal matrix object which is valid only immediately after the method is called. The matrix should not be modified or destroyed. To prevent the matrix from being destroyed, the returned matrix may be assigned to a GlgObjectC instance that will reference it. Even better, a copy of of the matrix may be stored to prevent the matrix from being modified.

Querying the drawing matrix of a viewport returns the drawing matrix used to position the viewport's control points, and not the matrix used to render the objects inside it. To get the drawing matrix the viewport uses to draw objects inside it, query the drawing list of the viewport (the Array resource of the viewport) and use it as a parameter of the GetDrawingMatrix method.

◆ GetMatrixData()

void GetMatrixData ( GlgMatrixData matrix_data)

Queries coefficients of this matrix.

This is a wrapper for GlgGetMatrixData.

Parameters
matrix_dataThe structure that will receive the returned matrix coefficients.

See GlgMatrixData for details.

◆ InverseMatrix()

GlgObject InverseMatrix ( void  )

Inverts this matrix object.

This is a wrapper for GlgCreateInversedMatrix.

Returns
The inverse of the input matrix. The returned matrix is a GlgObject object that must be explicitly dereferenced. If it is assigned to a GlgObjectC instance, use the instance's Drop method to dereference the returned matrix.

This method may be used to invert the drawing transformation obtained using GetDrawingMatrix. While the drawing transformation converts world to screen coordinates, the inverse of it may be used to convert the screen coordinates of objects and object bounding boxes back to world coordinates.

◆ ScreenToWorld()

GlgBoolean ScreenToWorld ( GlgBoolean  inside_vp,
GlgPoint in_point,
GlgPoint out_point 
)

Converts a point's screen coordinates to the GLG world coordinate system.

This is a wrapper for GlgScreenToWorld.

The method uses the world coordinate system of the object it is invoked on, which includes the effect of all drawing transformations attached to the object and all its parents.

Parameters
inside_vpIf this object is a viewport or a light viewport, inside_vp specifies which world coordinate system to use:
  • True to will use the world coordinate system used to draw objects inside this viewport object.
  • False, to use the world coordinate system used to draw this viewport object inside its parent viewport.
    The value of this parameter is ignored for objects other than a viewport or light viewport.
in_pointThe point to be converted.
out_pointThe point structure that will receive converted world coordinates.
Returns
Success or failure status.

The object's hierarchy must be set up to use this method.

When converting the cursor position to world coordinates, add GLG_COORD_MAPPING_ADJ to the cursor's X and Y screen coordinates for precise mapping.

◆ SetMatrixData()

void SetMatrixData ( GlgMatrixData matrix_data)

Sets coefficients of this matrix.

Parameters
matrix_dataThe new matrix's coefficients.

See GlgMatrixData for details.

◆ TransformPoint()

void TransformPoint ( GlgPoint in_point,
GlgPoint out_point 
)

Transforms a single point using this matrix.

This is a wrapper for GlgTransformPoint.

Parameters
in_pointThe input point to be transformed.
out_pointThe transformed point.

This method applies this transformation matrix to the in_point parameter, and returns the result in out_point.

◆ WorldToScreen()

GlgBoolean WorldToScreen ( GlgBoolean  inside_vp,
GlgPoint in_point,
GlgPoint out_point 
)

Converts a point's coordinates from the GLG world coordinate system to the screen coordinate system.

This is a wrapper for GlgWorldToScreen.

The method uses the world coordinate system of the object it is invoked on, which includes the effect of all drawing transformations attached to the object and all its parents.

Parameters
inside_vpIf this object is a viewport or a light viewport, inside_vp specifies which world coordinate system to use:
  • True to will use the world coordinate system used to draw objects inside this viewport object.
  • False, to use the world coordinate system used to draw this viewport object inside its parent viewport.

    The value of this parameter is ignored for objects other than a viewport or light viewport.

in_pointThe point to be converted.
out_pointThe point structure that will receive converted screen coordinates.
Returns
Success or failure status.

The object's hierarchy must be set up to use this method.