AT&T Home | AT&T Labs | Research
AT&T Labs, Inc. - Research

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YChart | YDAT | YWAIT | Byzgraf | FAQs
rotate (Number angle) typedict.Matrix
 
Changes this matrix so that the coordinate axes are rotated by angle degrees in the direction that takes the positive x-axis into the positive y-axis when angle is positive, which is often observed and as a clockwise rotation when objects are drawn on your screen, and returns this matrix to the caller. The mathematical description of rotate says it transforms the point
(x, y)
into
(x*cos(angle) - y*sin(angle), x*sin(angle) + y*cos(angle))
which means the new and old matrices map
(1, 0)
and
(cos(angle), sin(angle))
into the same point.
 
 Example:   The program,
import yoix.*.*;

DrawXAxis(Graphics graphics) {
    double axislength = 2.5*72;
    double ticklength = 72/16;
    double delta = axislength/10;
    int    n;

    graphics {               // "named block"
        gsave();
        moveto(0, 0);
        lineto(axislength, 0);
        moveto(delta, 0);
        for (n = 0; n < 10; n++) {
            rlineto(0, ticklength);
            rmoveto(delta, -ticklength);
        }
        stroke();
        grestore();
    }
}

DrawAxes(Graphics graphics) {
    graphics {               // "named block"
        gsave();
        DrawXAxis(graphics);
        rotate(90);          // prepare for y axis
        scale(1, -1);        // flipped for ticks
        DrawXAxis(graphics);
        grestore();
    }
}

JFrame f = {
    Color background = Color.white;

    paint(Rectangle rect) {
        graphics {          // "named block"
            gsave();
            translate(72, 72);
            setrgbcolor(1, 0, 0);
            DrawAxes(graphics);
            rotate(10);
            setrgbcolor(0, 0, 1);
            DrawAxes(graphics);
            grestore();
        }
    }
};

f.visible = TRUE;
defines functions that can draw simple coordinate axes and then defines a paint function in a frame that draws a set of axes in blue, applies a small rotation, and draws the new set of axes in red.
 
 Return:   Matrix
 
 See Also:   concat, concatmatrix, currentmatrix, dividematrix, dtransform, Graphics, identmatrix, idtransform, initmatrix, invertmatrix, itransform, maptopixel, scale, setmatrix, shear, transform, translate

 

Yoix is a registered trademark of AT&T Inc.