Home Forums GAMES在线课程(现代计算机图形学入门)讨论区 作业三框架中的判断三角形内外

Viewing 4 reply threads
  • Author
    Posts
    • #4433 Score: 3
      杰哥
      Participant
      2 pts

      不明白作业三框架中判断三角形内外的这个函数为什么可以这么写。

      This post has received 3 votes up.
      Attachments:
      You must be logged in to view attached files.
    • #4435 Score: 0
      Keneyr
      Participant
      7 pts

      +1

    • #4441 Score: 0
      clarence
      Participant
      -2 pt

      +1

    • #4443 Score: 1
      ljz
      Participant
      1 pt

      (我是从直观上面去理解,不是很严谨)在齐次坐标下两个点做叉积相当于定义了一条直线,二维上直线方程是 Ax+By+C = 0, 也就是(A,B,C).dot(x,y,1)=0, 那给你两个点v1(x1,y1,1),v2(x2,y2,1) 我们知道v1,v2和他们的叉积向量做点乘结果就是0,那么自然就可以他们的叉积作为(A,B,C),来确定直线v1-v2. 然后判断点在该直线的某一侧或是否在直线上,就用该点坐标去与这个(A,B,C)做点乘,为0 就在直线上, 两个点在直线的同一侧应该结果的符号是一样的. 代码应该就是在判断p点和v2点是否在v0-v1直线的同一侧, p点和v1是否在v2-v0直线的同一侧….., 只有这样P点才会在三角形内部, 大概如此??

      This post has received 1 vote up.
    • #7093 Score: 0
      Andy Chen
      Participant

      把v[0]看成向量,起点是原点

Viewing 4 reply threads
  • You must be logged in to reply to this topic.