Matrix Transformations

IGrafMatrix has a set of calls to support the common graphics transformations: identity, translate, scale and rotate. An empty constructor creates an identity matrix. These calls allow you to:

To set up a translate, rotate, or scaling matrix, call the translateBy, rotateBy, and scaleBy functions. To set up a matrix that will, for example, first scale and then rotate the graphic, call the scaleBy and rotateBy functions in sequence. The matrix stores the cumulative transformation so you can apply one matrix to various graphics instead of scaling and rotating each graphic explicitly.

The setToRotate, setToScale, and setToTranslate functions set the matrix to rotate, scale, or translate, respectively. These functions cannot be called in sequence like rotateBy, scaleBy, and translateBy. If you call them in sequence, only the last call has any effect.

Identity

An identity transformation does nothing when applied to a set of points and vectors. It sets the destination to the source when you call transformPoint(s) or unTransformPoint.

Translation

For translation, a delta point specifies the amount an object moves along the x and y axis. Function translateBy(IGPoint2D(2,0)) moves an object from the origin along the x axis by 2 units.

Rotation

The angle of rotation is in degrees and is measured from the positive x axis to the positive y axis. Rotation occurs around a point. The default rotation is about the origin.

Scaling

A point specifies scaling factors for x and y. A scale factor with x==y is a uniform scale. If a scale factor is greater than one, it enlarges the object. If the value is between zero and one, it shrinks the object. A scale factor that is less than zero mirrors an object.

Scaling is relative to the center of scale. That is, a point at the center doesn't change. Change increases the further a point is from the center. The default center of scale is the origin: (0,0).