expression
Model triangle coverage using edge functions
Rasterization determines which framebuffer samples are covered by a primitive. For a counterclockwise triangle in Cartesian y-up space, a point strictly inside has positive signed edge values. The tiny integer model excludes all boundaries; a real rasterizer uses specific shared-edge rules, sample locations and clipping. Expected result (NOT RUN): inside: true inside: false Common mistake: Assuming this strict-interior test reproduces exact GPU rasterization or handles every winding convention. Static Rust example; not a verified ByteMind executable assessment.
Formal Syntax & Structure
rust syntaxrust
edge(a,b,p) = (b.x-a.x)*(p.y-a.y) - (b.y-a.y)*(p.x-a.x)Working Example
Example Snippetrust
fn edge(a: [i32;2], b: [i32;2], p: [i32;2]) -> i32 { (b[0]-a[0])*(p[1]-a[1])-(b[1]-a[1])*(p[0]-a[0])}fn main() { let (a,b,c)=([0,0],[4,0],[0,4]); for p in [[1,1],[3,3]] { println!("inside: {}", edge(a,b,p)>0 && edge(b,c,p)>0 && edge(c,a,p)>0); }}