Axis rotation
This argument list takes an angle in degrees and an axis. The graphic rotates counterclockwise around the axis at the specified angle. Figure 146 shows a 30 degree rotation around the x axis.
virtual void MGraphic3D::RotateBy( GDegrees angle, TGrafMatrix3D::EAxis axis );
axis: The x, y, or z axis around which the rotation occurs. TGrafMatrix3D has the following enumeration values that you supply for this parameter: kAboutXAxis, kAboutYAxis, kAboutZAxis.
The following code fragment draws a rounded box sweep (shown on the left in Figure 146
), and then translates it 250 world-coordinate units in the x direction and rotates it 30 degrees (shown on the right in Figure 146). The rounded box sweep is 200 world-coordinate units deep and high, with a round radius of 20. The round radius is used to calculate the rounded corners of the box sweep. The origin is in the center of the rounded box sweep, and the camera position is TGPoint3D(1440, 0, 1440).
TRoundedBox3D box( 200, 200, 20 ); box.Draw( thePort ); box.TranslateBy( TGPoint3D( 250, 0, 0 ) ); box.RotateBy( 30, TGrafMatrix3D = kAboutXAxis ); box.Draw( port );
virtual void MGraphic3D::RotateBy( GDegrees angle, const TGLine3D& ray );
ray: An arbitrary vector around which the rotation occurs. The direction of the vector determines the orientation of the rotation, which is counter-clockwise around the vector. The endpoint of TGLine3D determines the direction of the ray.
The following code fragment translates the rounded box sweep by 250 worldcoordinate units in the x direction, and rotates it 30 degrees around a ray.
box.TranslateBy( TGPoint3D( 250, 0, 0 ) ); TGLine3D ray( TGPoint3D( 1, 0, 0 ), TGPoint3D( 150, 150, 0 ) ); box.RotateBy( 30, ray ); box.Draw( port );
virtual void MGraphic3D::ScaleBy( const TGPoint3D& factor, const TGPoint3D& centerOfScale );
centerOfScale: The center of scale determines the point around which the graphic is scaled. A center of scale other than the center of the graphic can scale the graphic beyond the visible area of the view.
Figure 148
shows uses three different centers of scale on the rounded box sweep. From left to right, the centers of scale are the center of the graphic, the origin, and a point.
The effect of negative scale factors is the same as mirroring. Scaling by 1.0 in the x direction is like mirroring about the yz plane. A negative scale factor in the y direction is like mirroring about the xz plane. A negative scale factor in the z direction is like mirroring about the xy plane.
Figure 149
Center of graphic
box.ScaleBy( TGPoint3D( .5, .5, .5 ), box.GetGeometricBounds().GetCenter() );
box.Draw( port );
Origin of View
TGPoint3D( )
Negative scale factor
[Contents]
[Previous]
[Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.