Home Forums GAMES在线课程(现代计算机图形学入门)讨论区 作业1 高阶任务 绕X、Y轴旋转效果图 是否正确?

Tagged: 

Viewing 2 reply threads
  • Author
    Posts
    • #9118 Score: 0
      huhuhuhu
      Participant

      按照接口定义Eigen::Matrix4f get_rotation(Vector3f axis, float angle) 用XYZ轴简单验证下
      Vector3f axisX(1.0f, 0.0f, 0.0f);
      Vector3f axisY(0.0f, 1.0f, 0.0f);
      Vector3f axisZ(0.0f, 0.0f, 1.0f);

      贴下动图,想请教下对不对

      Attachments:
      You must be logged in to view attached files.
    • #10512 Score: 0
      DT
      Participant

      我也是这样的,但是我的沿 X 轴旋转如果离屏幕过近程序就会崩溃退出,不知道你有没有碰到这个问题呢?

      • This reply was modified 2 years, 2 months ago by DT.
      • #10803 Score: 0
        whiteandbright
        Participant

        我也遇到闪退的问题了,请问您解决了吗

        • #10810 Score: 2
          炎炎夏日丽丽在目
          Participant
          2 pts

          void rst::rasterizer::set_pixel(const Eigen::Vector3f& point, const Eigen::Vector3f& color)
          {
          //old index: auto ind = point.y() + point.x() * width;
          if (point.x() < 0 || point.x() >= width ||
          point.y() < 0 || point.y() >= height) return;
          auto ind = (height-point.y())*width + point.x();
          // if out of range, return
          if (ind >= width * height) return;
          frame_buf[ind] = color;
          }
          闪退是因为在set_pixel计算ind的时候,超出屏幕外的三角形边上的点对应的ind会大于或者等于width * weight,而frame_buf的大小为width * weight,所以会发生数组访问越界错误,加上这个判断即可

          This post has received 2 votes up.
          • #10814 Score: 0
            DT
            Participant

            感谢!想到了但还没时间改,看来没想错

    • #12020 Score: 0
      unkvcc
      Participant
      2 pts

      作业一提高部分报错
      问题记录:
      按照课件的罗格里德斯旋转公式,绕任意轴z轴旋转时,发现三角形先会变大再变小
      分析成因:
      因为我将三维向量都转化为四维,最后才代入公式计算
      解决:
      如果先计算完公式,再组合成四维矩阵,就不会出现这样的问题

      • #12021 Score: 0
        unkvcc
        Participant
        2 pts

        我将远近屏幕的正值改为了负值,改后的三角形朝上,绕X轴旋转起来跟你的不一样

        • This reply was modified 1 year, 8 months ago by unkvcc.
        Attachments:
        You must be logged in to view attached files.
Viewing 2 reply threads
  • You must be logged in to reply to this topic.