]> Dogcows Code - chaz/rasterize/blob - tri.c
initial commit
[chaz/rasterize] / tri.c
1
2 /*
3 * CS5600 University of Utah
4 * Charles McGarvey
5 * mcgarvey@eng.utah.edu
6 */
7
8 #include "tri.h"
9
10 vec_t tri_barycentric(const tri_t* t, vec_t v)
11 {
12 vec_t c = VEC_ZERO;
13 scal_t denom = (t->b.v.y - t->c.v.y) * (t->a.v.x - t->c.v.x) + (t->c.v.x - t->b.v.x) * (t->a.v.y - t->c.v.y);
14 c.x = ((t->b.v.y - t->c.v.y) * (v.x - t->c.v.x) + (t->c.v.x - t->b.v.x) * (v.y - t->c.v.y)) / denom;
15 c.y = ((t->c.v.y - t->a.v.y) * (v.x - t->c.v.x) + (t->a.v.x - t->c.v.x) * (v.y - t->c.v.y)) / denom;
16 c.z = S(1.0) - c.x - c.y;
17 return c;
18 }
19
This page took 0.036954 seconds and 5 git commands to generate.