RotateBy

MGraphic::RotateBy rotates the graphic clockwise around a center of rotation by the specified angle.

      virtual void MGraphic::RotateBy( const GDegrees angle, 
                                       const TGPoint& centerOfRotation = TGPoint::kOrigin );
angle: The amount of the rotation in degrees. Positive values rotate in a clockwise direction.

centerOfRotation: The default center of rotation is TGPoint::kOrigin (the upper-left corner of the view). The center of rotation determines the point around which the graphic is rotated. A center of rotation other than the center of the graphic can rotate the graphic beyond the visible area of the view.

Figure 24 shows a shape rotated three times with a different center of rotation each time. The shape after it has been rotated is shown filled.


Center of graphic

      shape->RotateBy( 15, shape->GetGeometricBounds().GetCenter() );
      shape->Draw( thePort );

Origin of view

    shape->RotateBy( 15, TGPoint::kOrigin ); shape->Draw( thePort );

TGPoint( 0, 200 )

    shape->RotateBy( 15, TGPoint( 0, 200 ) ); shape->Draw( thePort );
You might want to refer to a book on matrix multiplication, particularly a section on rotation matrices, to see how the new points are calculated for this example.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker