当前位置: 首页>>代码示例>>C++>>正文


C++ Matrix3x3::identity方法代码示例

本文整理汇总了C++中Matrix3x3::identity方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix3x3::identity方法的具体用法?C++ Matrix3x3::identity怎么用?C++ Matrix3x3::identity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Matrix3x3的用法示例。


在下文中一共展示了Matrix3x3::identity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: process_input

void process_input(Matrix3x3 &M){
    char command[1024];
    bool done;
    float theta, s, cx, cy;
    float sx, sy, shx, shy, px, py;
    int dx, dy;

   /* build identity matrix */
    M.identity();

    for(done = false; !done;) {
        /* prompt and accept input, converting text to lower case */
        cout  << "> ";
        cin >> command;
        lowercase(command);

        /* parse the input command, and read parameters as needed */
        if(strcmp(command, "d") == 0) {
            done = true;
            imageData =  Manipulation::warper(imageData, M);
        }
        else if(strcmp(command, "n") == 0) {// twirl 
            if(cin >> s >> cx >> cy)
                imageData = Manipulation::twirl(imageData, s, cx, cy);
            else
                cout << "invalid twirl parameter\n";
            done = true;
        }
        else if(strlen(command) != 1) {
开发者ID:weirwood,项目名称:graph-image,代码行数:29,代码来源:warper.cpp

示例2: process_input

/*
   Routine to build a projective transform from input text, display, or
   write transformed image to a file
 */
void process_input(Matrix3x3 &M) {
    char command[1024];
    bool done;
    float theta;

    float inputX;
    float inputY;
    float inputZ;
    /* build identity matrix */
    M.identity();

    for(done = false; !done;) {

        /* prompt and accept input, converting text to lower case */
        printf("> ");
        scanf("%s", command);
        lowercase(command);

        /* parse the input command, and read parameters as needed */
        if(strcmp(command, "d") == 0) {
            done = true;
        } else if(strlen(command) != 1) {
            printf("invalid command, enter r, s, t, h, d\n");
        } else {
            switch(command[0]) {

            case 'r':		/* Rotation, accept angle in degrees */
                if(scanf("%f", &theta) == 1)
                    Rotate(M, theta);
                else
                    fprintf(stderr, "invalid rotation angle\n");
                break;
            case 's':		/* Scale, accept scale factors */
                if(scanf("%f %f", &inputX, &inputY))
                    Scale(M, inputX, inputY);
                else
                    fprintf(stderr,"invalid scaling input\n");

                break;
            case 't':		/* Translation, accept translations */
                if(scanf("%f %f", &inputX, &inputY))
                    Translate(M, inputX, inputY);
                else
                    fprintf(stderr,"invalid scaling input\n");

                break;
            case 'h':		/* Shear, accept shear factors */
                if(scanf("%f %f", &inputX, &inputY))
                    Shear(M, inputX, inputY);
                else
                    fprintf(stderr,"invalid scaling input\n");
                break;
            //twirl mode on
            case 'n':
                if(scanf("%f %f %f", &inputX, &inputY, &inputZ)) {
                    manager.turnTwrilModeOn(inputX, inputY, inputZ);
                } else {
                    fprintf(stderr, "invalid scaling input\n");
                }
                break;
            case 'p':
                if(scanf("%f %f", &inputX, &inputY))
                    Perspective(M, inputX, inputY);
                else
                    fprintf(stderr,"invalid scaling input\n");
                break;
            case 'd':		/* Done, that's all for now */
                done = true;
                break;
            default:
                printf("invalid command, enter r, s, t, h, d\n");
            }
        }
    }
}
开发者ID:sylvanchil,项目名称:6040,代码行数:79,代码来源:main.cpp


注:本文中的Matrix3x3::identity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。