import{_ as l,c as a,a as m,b as Q,d as n,o as t}from"./app-DazB1p5v.js";const s="/assets/edge_function-CExU8wfA.svg",d="/assets/edge_function2-DxwnclKC.svg",e="/assets/edge_function3-Dc2XUPY2.svg",o="/assets/d3d10-rasterrulestriangle-BIbvKB8l.png",r="/assets/edge_function4-Bqfpv0Aa.svg",g={},p={class:"MathJax",jax:"SVG",style:{position:"relative"}},h={style:{"vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"9.584ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 4236.3 1000","aria-hidden":"true"},i={class:"MathJax",jax:"SVG",style:{position:"relative"}},H={style:{"vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"9.584ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 4236.3 1000","aria-hidden":"true"},u={class:"MathJax",jax:"SVG",style:{position:"relative"}},c={style:{"vertical-align":"-0.375ex"},xmlns:"http://www.w3.org/2000/svg",width:"2.44ex",height:"1.92ex",role:"img",focusable:"false",viewBox:"0 -683 1078.6 848.6","aria-hidden":"true"},f={class:"MathJax",jax:"SVG",style:{position:"relative"}},M={style:{"vertical-align":"-0.339ex"},xmlns:"http://www.w3.org/2000/svg",width:"2.44ex",height:"1.885ex",role:"img",focusable:"false",viewBox:"0 -683 1078.6 833","aria-hidden":"true"},Z={class:"MathJax",jax:"SVG",style:{position:"relative"}},L={style:{"vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"6.868ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 3035.7 1000","aria-hidden":"true"},x={class:"MathJax",jax:"SVG",display:"true",width:"full",style:{"min-width":"62.09ex",position:"relative"}},w={style:{"vertical-align":"-2.416ex","min-width":"62.09ex"},xmlns:"http://www.w3.org/2000/svg",width:"100%",height:"5.964ex",role:"img",focusable:"false","aria-hidden":"true"},b={class:"MathJax",jax:"SVG",style:{position:"relative"}},V={style:{"vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"10.372ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 4584.2 1000","aria-hidden":"true"},y={class:"MathJax",jax:"SVG",style:{position:"relative"}},v={style:{"vertical-align":"0"},xmlns:"http://www.w3.org/2000/svg",width:"1.699ex",height:"1.545ex",role:"img",focusable:"false",viewBox:"0 -683 751 683","aria-hidden":"true"},D={class:"MathJax",jax:"SVG",style:{position:"relative"}},k={style:{"vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"10.372ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 4584.2 1000","aria-hidden":"true"},j={class:"MathJax",jax:"SVG",style:{position:"relative"}},C={style:{"vertical-align":"0"},xmlns:"http://www.w3.org/2000/svg",width:"1.699ex",height:"1.545ex",role:"img",focusable:"false",viewBox:"0 -683 751 683","aria-hidden":"true"},B={class:"MathJax",jax:"SVG",style:{position:"relative"}},S={style:{"vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"10.372ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 4584.2 1000","aria-hidden":"true"},J={class:"MathJax",jax:"SVG",style:{position:"relative"}},G={style:{"vertical-align":"0"},xmlns:"http://www.w3.org/2000/svg",width:"1.699ex",height:"1.545ex",role:"img",focusable:"false",viewBox:"0 -683 751 683","aria-hidden":"true"},_={class:"MathJax",jax:"SVG",display:"true",style:{position:"relative"}},P={style:{"vertical-align":"-2.036ex"},xmlns:"http://www.w3.org/2000/svg",width:"61.694ex",height:"5.204ex",role:"img",focusable:"false",viewBox:"0 -1400 27268.9 2300","aria-hidden":"true"},E={class:"MathJax",jax:"SVG",display:"true",style:{position:"relative"}},R={style:{"vertical-align":"-3.507ex"},xmlns:"http://www.w3.org/2000/svg",width:"29.166ex",height:"8.145ex",role:"img",focusable:"false",viewBox:"0 -2050 12891.2 3600","aria-hidden":"true"},z={class:"MathJax",jax:"SVG",display:"true",width:"full",style:{"min-width":"36.765ex",position:"relative"}},A={style:{"vertical-align":"-0.566ex","min-width":"36.765ex"},xmlns:"http://www.w3.org/2000/svg",width:"100%",height:"2.262ex",role:"img",focusable:"false","aria-hidden":"true"};function O(F,T){return t(),a("div",null,[T[43]||(T[43]=m('

边界判定


4. 边界判定

4.1 边界函数(Edge Function)

',4)),Q("p",null,[T[10]||(T[10]=n("设二维平面上的一条直线,上面有两个点")),Q("mjx-container",p,[(t(),a("svg",h,T[0]||(T[0]=[m('',1)]))),T[1]||(T[1]=Q("mjx-assistive-mml",{unselectable:"on",display:"inline"},[Q("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[Q("msub",null,[Q("mi",null,"P"),Q("mn",null,"0")]),Q("mo",{stretchy:"false"},"("),Q("msub",null,[Q("mi",null,"x"),Q("mn",null,"0")]),Q("mo",null,","),Q("msub",null,[Q("mi",null,"y"),Q("mn",null,"0")]),Q("mo",{stretchy:"false"},")")])],-1))]),T[11]||(T[11]=n("和")),Q("mjx-container",i,[(t(),a("svg",H,T[2]||(T[2]=[m('',1)]))),T[3]||(T[3]=Q("mjx-assistive-mml",{unselectable:"on",display:"inline"},[Q("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[Q("msub",null,[Q("mi",null,"P"),Q("mn",null,"1")]),Q("mo",{stretchy:"false"},"("),Q("msub",null,[Q("mi",null,"x"),Q("mn",null,"1")]),Q("mo",null,","),Q("msub",null,[Q("mi",null,"y"),Q("mn",null,"1")]),Q("mo",{stretchy:"false"},")")])],-1))]),T[12]||(T[12]=n(",这里假设直线的方向是从")),Q("mjx-container",u,[(t(),a("svg",c,T[4]||(T[4]=[m('',1)]))),T[5]||(T[5]=Q("mjx-assistive-mml",{unselectable:"on",display:"inline"},[Q("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[Q("msub",null,[Q("mi",null,"P"),Q("mn",null,"0")])])],-1))]),T[13]||(T[13]=n("到")),Q("mjx-container",f,[(t(),a("svg",M,T[6]||(T[6]=[m('',1)]))),T[7]||(T[7]=Q("mjx-assistive-mml",{unselectable:"on",display:"inline"},[Q("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[Q("msub",null,[Q("mi",null,"P"),Q("mn",null,"1")])])],-1))]),T[14]||(T[14]=n(",那么直线把整个二维平面分成两部分,“左边”和“右边”。那么对于这个平面上任意一点")),Q("mjx-container",Z,[(t(),a("svg",L,T[8]||(T[8]=[m('',1)]))),T[9]||(T[9]=Q("mjx-assistive-mml",{unselectable:"on",display:"inline"},[Q("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[Q("mi",null,"P"),Q("mo",{stretchy:"false"},"("),Q("mi",null,"x"),Q("mo",null,","),Q("mi",null,"y"),Q("mo",{stretchy:"false"},")")])],-1))]),T[15]||(T[15]=n(",定义二维函数"))]),Q("mjx-container",x,[(t(),a("svg",w,T[16]||(T[16]=[m('',1)]))),T[17]||(T[17]=Q("mjx-assistive-mml",{unselectable:"on",display:"block"},[Q("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[Q("mtable",{displaystyle:"true"},[Q("mlabeledtr",null,[Q("mtd",null,[Q("mtext",null,"(4.1.1)")]),Q("mtd",null,[Q("mtable",{displaystyle:"true",columnalign:"right left",columnspacing:"0em",rowspacing:"3pt"},[Q("mtr",null,[Q("mtd",null,[Q("mi",null,"e"),Q("mo",{stretchy:"false"},"("),Q("mi",null,"x"),Q("mo",null,","),Q("mi",null,"y"),Q("mo",{stretchy:"false"},")")]),Q("mtd",null,[Q("mi"),Q("mo",null,"="),Q("mo",{"data-mjx-texclass":"ORD"},"∥"),Q("mrow",{"data-mjx-texclass":"ORD"},[Q("mover",null,[Q("mrow",null,[Q("msub",null,[Q("mi",null,"P"),Q("mn",null,"0")]),Q("msub",null,[Q("mi",null,"P"),Q("mn",null,"1")])]),Q("mo",{stretchy:"false"},"→")])]),Q("mo",null,"×"),Q("mrow",{"data-mjx-texclass":"ORD"},[Q("mover",null,[Q("mrow",null,[Q("msub",null,[Q("mi",null,"P"),Q("mn",null,"0")]),Q("mi",null,"P")]),Q("mo",{stretchy:"false"},"→")])]),Q("mo",{"data-mjx-texclass":"ORD"},"∥")])]),Q("mtr",null,[Q("mtd"),Q("mtd",null,[Q("mi"),Q("mo",null,"="),Q("mo",{stretchy:"false"},"("),Q("msub",null,[Q("mi",null,"x"),Q("mn",null,"1")]),Q("mo",null,"−"),Q("msub",null,[Q("mi",null,"x"),Q("mn",null,"0")]),Q("mo",{stretchy:"false"},")"),Q("mo",{stretchy:"false"},"("),Q("mi",null,"y"),Q("mo",null,"−"),Q("msub",null,[Q("mi",null,"y"),Q("mn",null,"0")]),Q("mo",{stretchy:"false"},")"),Q("mo",null,"−"),Q("mo",{stretchy:"false"},"("),Q("msub",null,[Q("mi",null,"y"),Q("mn",null,"1")]),Q("mo",null,"−"),Q("msub",null,[Q("mi",null,"y"),Q("mn",null,"0")]),Q("mo",{stretchy:"false"},")"),Q("mo",{stretchy:"false"},"("),Q("mi",null,"x"),Q("mo",null,"−"),Q("msub",null,[Q("mi",null,"x"),Q("mn",null,"0")]),Q("mo",{stretchy:"false"},")")])])])])])])])],-1))]),Q("p",null,[T[30]||(T[30]=n("称这个函数为这条直线的边界函数(Edge Function),当")),Q("mjx-container",b,[(t(),a("svg",V,T[18]||(T[18]=[m('',1)]))),T[19]||(T[19]=Q("mjx-assistive-mml",{unselectable:"on",display:"inline"},[Q("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[Q("mi",null,"e"),Q("mo",{stretchy:"false"},"("),Q("mi",null,"x"),Q("mo",null,","),Q("mi",null,"y"),Q("mo",{stretchy:"false"},")"),Q("mo",null,">"),Q("mn",null,"0")])],-1))]),T[31]||(T[31]=n("时,")),Q("mjx-container",y,[(t(),a("svg",v,T[20]||(T[20]=[Q("g",{stroke:"currentColor",fill:"currentColor","stroke-width":"0",transform:"scale(1,-1)"},[Q("g",{"data-mml-node":"math"},[Q("g",{"data-mml-node":"mi"},[Q("path",{"data-c":"1D443",d:"M287 628Q287 635 230 637Q206 637 199 638T192 648Q192 649 194 659Q200 679 203 681T397 683Q587 682 600 680Q664 669 707 631T751 530Q751 453 685 389Q616 321 507 303Q500 302 402 301H307L277 182Q247 66 247 59Q247 55 248 54T255 50T272 48T305 46H336Q342 37 342 35Q342 19 335 5Q330 0 319 0Q316 0 282 1T182 2Q120 2 87 2T51 1Q33 1 33 11Q33 13 36 25Q40 41 44 43T67 46Q94 46 127 49Q141 52 146 61Q149 65 218 339T287 628ZM645 554Q645 567 643 575T634 597T609 619T560 635Q553 636 480 637Q463 637 445 637T416 636T404 636Q391 635 386 627Q384 621 367 550T332 412T314 344Q314 342 395 342H407H430Q542 342 590 392Q617 419 631 471T645 554Z"})])])],-1)]))),T[21]||(T[21]=Q("mjx-assistive-mml",{unselectable:"on",display:"inline"},[Q("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[Q("mi",null,"P")])],-1))]),T[32]||(T[32]=n("位于直线的左侧,当")),Q("mjx-container",D,[(t(),a("svg",k,T[22]||(T[22]=[m('',1)]))),T[23]||(T[23]=Q("mjx-assistive-mml",{unselectable:"on",display:"inline"},[Q("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[Q("mi",null,"e"),Q("mo",{stretchy:"false"},"("),Q("mi",null,"x"),Q("mo",null,","),Q("mi",null,"y"),Q("mo",{stretchy:"false"},")"),Q("mo",null,"<"),Q("mn",null,"0")])],-1))]),T[33]||(T[33]=n("时,")),Q("mjx-container",j,[(t(),a("svg",C,T[24]||(T[24]=[Q("g",{stroke:"currentColor",fill:"currentColor","stroke-width":"0",transform:"scale(1,-1)"},[Q("g",{"data-mml-node":"math"},[Q("g",{"data-mml-node":"mi"},[Q("path",{"data-c":"1D443",d:"M287 628Q287 635 230 637Q206 637 199 638T192 648Q192 649 194 659Q200 679 203 681T397 683Q587 682 600 680Q664 669 707 631T751 530Q751 453 685 389Q616 321 507 303Q500 302 402 301H307L277 182Q247 66 247 59Q247 55 248 54T255 50T272 48T305 46H336Q342 37 342 35Q342 19 335 5Q330 0 319 0Q316 0 282 1T182 2Q120 2 87 2T51 1Q33 1 33 11Q33 13 36 25Q40 41 44 43T67 46Q94 46 127 49Q141 52 146 61Q149 65 218 339T287 628ZM645 554Q645 567 643 575T634 597T609 619T560 635Q553 636 480 637Q463 637 445 637T416 636T404 636Q391 635 386 627Q384 621 367 550T332 412T314 344Q314 342 395 342H407H430Q542 342 590 392Q617 419 631 471T645 554Z"})])])],-1)]))),T[25]||(T[25]=Q("mjx-assistive-mml",{unselectable:"on",display:"inline"},[Q("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[Q("mi",null,"P")])],-1))]),T[34]||(T[34]=n("位于直线的右侧,当")),Q("mjx-container",B,[(t(),a("svg",S,T[26]||(T[26]=[m('',1)]))),T[27]||(T[27]=Q("mjx-assistive-mml",{unselectable:"on",display:"inline"},[Q("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[Q("mi",null,"e"),Q("mo",{stretchy:"false"},"("),Q("mi",null,"x"),Q("mo",null,","),Q("mi",null,"y"),Q("mo",{stretchy:"false"},")"),Q("mo",null,"="),Q("mn",null,"0")])],-1))]),T[35]||(T[35]=n("时,表示")),Q("mjx-container",J,[(t(),a("svg",G,T[28]||(T[28]=[Q("g",{stroke:"currentColor",fill:"currentColor","stroke-width":"0",transform:"scale(1,-1)"},[Q("g",{"data-mml-node":"math"},[Q("g",{"data-mml-node":"mi"},[Q("path",{"data-c":"1D443",d:"M287 628Q287 635 230 637Q206 637 199 638T192 648Q192 649 194 659Q200 679 203 681T397 683Q587 682 600 680Q664 669 707 631T751 530Q751 453 685 389Q616 321 507 303Q500 302 402 301H307L277 182Q247 66 247 59Q247 55 248 54T255 50T272 48T305 46H336Q342 37 342 35Q342 19 335 5Q330 0 319 0Q316 0 282 1T182 2Q120 2 87 2T51 1Q33 1 33 11Q33 13 36 25Q40 41 44 43T67 46Q94 46 127 49Q141 52 146 61Q149 65 218 339T287 628ZM645 554Q645 567 643 575T634 597T609 619T560 635Q553 636 480 637Q463 637 445 637T416 636T404 636Q391 635 386 627Q384 621 367 550T332 412T314 344Q314 342 395 342H407H430Q542 342 590 392Q617 419 631 471T645 554Z"})])])],-1)]))),T[29]||(T[29]=Q("mjx-assistive-mml",{unselectable:"on",display:"inline"},[Q("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[Q("mi",null,"P")])],-1))]),T[36]||(T[36]=n("恰好在直线上"))]),T[44]||(T[44]=m('

4.2 判定三角形内外

对于逆时针排列三角形,如果一个点如果在三角形内,那么这个点一定在所有三条边的“左侧”,反之,只要有这个点出现在任意一条边的“右侧”,那么这个点就是在三角形的外部

4.3 判定三角形的边(Top-Left规则)

如果一个点出恰好现在三角形某个边上,也就是某个EdgeFunction的值恰好为零,需要根据Top-Left规则来判定这个点是否归属改三角形。 这是由于图形学中会出现两个三角形共享一条边的情况,而这种情况下边上的点应该只归属其中一个三角形,Top-Left是一个约定的规则:

如果边出现三角形左侧或者恰好是水平方向最上面的边,则这种边属于这个三角形

例如上面的三角形,实线边是属于这个三角形的,虚线边则不属于。 DirectX的光栅化规则也是遵守的这个规则

如果一个点是两个边的公有点,则只有在这两条边都是属于三角形的边的情况下,这个顶点才是属于这个三角形的,以保证在光栅化过程中,所有点都属于唯一的某个三角形,例如下面的一个比较极端的例子,对8个小三角形的光栅化

4.4 三角形内部判断

边界函数4.1.1可以变形为

',14)),Q("mjx-container",_,[(t(),a("svg",P,T[37]||(T[37]=[m('',1)]))),T[38]||(T[38]=Q("mjx-assistive-mml",{unselectable:"on",display:"block"},[Q("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[Q("mtable",{displaystyle:"true",columnalign:"right left",columnspacing:"0em",rowspacing:"3pt"},[Q("mtr",null,[Q("mtd",null,[Q("mi",null,"e"),Q("mo",{stretchy:"false"},"("),Q("mi",null,"x"),Q("mo",null,","),Q("mi",null,"y"),Q("mo",{stretchy:"false"},")")]),Q("mtd",null,[Q("mi"),Q("mo",null,"="),Q("mo",{stretchy:"false"},"("),Q("msub",null,[Q("mi",null,"x"),Q("mn",null,"1")]),Q("mo",null,"−"),Q("msub",null,[Q("mi",null,"x"),Q("mn",null,"0")]),Q("mo",{stretchy:"false"},")"),Q("mo",{stretchy:"false"},"("),Q("mi",null,"y"),Q("mo",null,"−"),Q("msub",null,[Q("mi",null,"y"),Q("mn",null,"0")]),Q("mo",{stretchy:"false"},")"),Q("mo",null,"−"),Q("mo",{stretchy:"false"},"("),Q("msub",null,[Q("mi",null,"y"),Q("mn",null,"1")]),Q("mo",null,"−"),Q("msub",null,[Q("mi",null,"y"),Q("mn",null,"0")]),Q("mo",{stretchy:"false"},")"),Q("mo",{stretchy:"false"},"("),Q("mi",null,"x"),Q("mo",null,"−"),Q("msub",null,[Q("mi",null,"x"),Q("mn",null,"0")]),Q("mo",{stretchy:"false"},")")])]),Q("mtr",null,[Q("mtd"),Q("mtd",null,[Q("mi"),Q("mo",null,"="),Q("mo",null,"−"),Q("mo",{stretchy:"false"},"("),Q("msub",null,[Q("mi",null,"y"),Q("mn",null,"1")]),Q("mo",null,"−"),Q("msub",null,[Q("mi",null,"y"),Q("mn",null,"0")]),Q("mo",{stretchy:"false"},")"),Q("mi",null,"x"),Q("mo",null,"+"),Q("mo",{stretchy:"false"},"("),Q("msub",null,[Q("mi",null,"x"),Q("mn",null,"1")]),Q("mo",null,"−"),Q("msub",null,[Q("mi",null,"x"),Q("mn",null,"0")]),Q("mo",{stretchy:"false"},")"),Q("mi",null,"y"),Q("mo",null,"+"),Q("mo",{stretchy:"false"},"("),Q("msub",null,[Q("mi",null,"y"),Q("mn",null,"1")]),Q("mo",null,"−"),Q("msub",null,[Q("mi",null,"y"),Q("mn",null,"0")]),Q("mo",{stretchy:"false"},")"),Q("msub",null,[Q("mi",null,"x"),Q("mn",null,"0")]),Q("mo",null,"−"),Q("mo",{stretchy:"false"},"("),Q("msub",null,[Q("mi",null,"x"),Q("mn",null,"1")]),Q("mo",null,"−"),Q("msub",null,[Q("mi",null,"x"),Q("mn",null,"0")]),Q("mo",{stretchy:"false"},")"),Q("msub",null,[Q("mi",null,"y"),Q("mn",null,"0")])])])])])],-1))]),T[45]||(T[45]=Q("p",null,"如果设",-1)),Q("mjx-container",E,[(t(),a("svg",R,T[39]||(T[39]=[m('',1)]))),T[40]||(T[40]=Q("mjx-assistive-mml",{unselectable:"on",display:"block"},[Q("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[Q("mtable",{displaystyle:"true",columnalign:"right left",columnspacing:"0em",rowspacing:"3pt"},[Q("mtr",null,[Q("mtd",null,[Q("mi",null,"a")]),Q("mtd",null,[Q("mi"),Q("mo",null,"="),Q("mo",null,"−"),Q("mo",{stretchy:"false"},"("),Q("msub",null,[Q("mi",null,"y"),Q("mn",null,"1")]),Q("mo",null,"−"),Q("msub",null,[Q("mi",null,"y"),Q("mn",null,"0")]),Q("mo",{stretchy:"false"},")")])]),Q("mtr",null,[Q("mtd",null,[Q("mi",null,"b")]),Q("mtd",null,[Q("mi"),Q("mo",null,"="),Q("msub",null,[Q("mi",null,"x"),Q("mn",null,"1")]),Q("mo",null,"−"),Q("msub",null,[Q("mi",null,"x"),Q("mn",null,"0")])])]),Q("mtr",null,[Q("mtd",null,[Q("mi",null,"c")]),Q("mtd",null,[Q("mi"),Q("mo",null,"="),Q("mo",{stretchy:"false"},"("),Q("msub",null,[Q("mi",null,"y"),Q("mn",null,"1")]),Q("mo",null,"−"),Q("msub",null,[Q("mi",null,"y"),Q("mn",null,"0")]),Q("mo",{stretchy:"false"},")"),Q("msub",null,[Q("mi",null,"x"),Q("mn",null,"0")]),Q("mo",null,"−"),Q("mo",{stretchy:"false"},"("),Q("msub",null,[Q("mi",null,"x"),Q("mn",null,"1")]),Q("mo",null,"−"),Q("msub",null,[Q("mi",null,"x"),Q("mn",null,"0")]),Q("mo",{stretchy:"false"},")"),Q("msub",null,[Q("mi",null,"y"),Q("mn",null,"0")])])])])])],-1))]),T[46]||(T[46]=Q("p",null,"则边界函数可以写作",-1)),Q("mjx-container",z,[(t(),a("svg",A,T[41]||(T[41]=[m('',1)]))),T[42]||(T[42]=Q("mjx-assistive-mml",{unselectable:"on",display:"block"},[Q("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[Q("mtable",{displaystyle:"true"},[Q("mlabeledtr",null,[Q("mtd",null,[Q("mtext",null,"(4.4.1)")]),Q("mtd",null,[Q("mi",null,"e"),Q("mo",{stretchy:"false"},"("),Q("mi",null,"x"),Q("mo",null,","),Q("mi",null,"y"),Q("mo",{stretchy:"false"},")"),Q("mo",null,"="),Q("mi",null,"a"),Q("mi",null,"x"),Q("mo",null,"+"),Q("mi",null,"b"),Q("mi",null,"y"),Q("mo",null,"+"),Q("mi",null,"c")])])])])],-1))]),T[47]||(T[47]=m(`

结合上面对于是否在三角形内以及三角形边上的判断,最终判断某点是否属于三角形,使用下面的函数判断该点是否在三角形三个边的内部

bool Inside(a,b,c, x, y) 
{
	bool is_top_left = (a!=0)?(a>0):(b<0);
	e=a*x+b*y+c;
	return e>0 || (e==0 && is_top_left);
}

如果这个点出现在三个边的内部,则该点在三角形内部

`,3))])}const N=l(g,[["render",O],["__file","raster02.html.vue"]]),Y=JSON.parse('{"path":"/note/graphics/rasterization/raster02.html","title":"边界判定","lang":"zh-CN","frontmatter":{},"headers":[{"level":2,"title":"4. 边界判定","slug":"_4-边界判定","link":"#_4-边界判定","children":[{"level":3,"title":"4.1 边界函数(Edge Function)","slug":"_4-1-边界函数-edge-function","link":"#_4-1-边界函数-edge-function","children":[]},{"level":3,"title":"4.2 判定三角形内外","slug":"_4-2-判定三角形内外","link":"#_4-2-判定三角形内外","children":[]},{"level":3,"title":"4.3 判定三角形的边(Top-Left规则)","slug":"_4-3-判定三角形的边-top-left规则","link":"#_4-3-判定三角形的边-top-left规则","children":[]},{"level":3,"title":"4.4 三角形内部判断","slug":"_4-4-三角形内部判断","link":"#_4-4-三角形内部判断","children":[]}]}],"git":{},"filePathRelative":"note/graphics/rasterization/raster02.md"}');export{N as comp,Y as data};