]>
Dogcows Code - chaz/rasterize/blob - tri.h
3 * CS5600 University of Utah
5 * mcgarvey@eng.utah.edu
16 * A triangle is a polygon of three vertices.
24 typedef struct tri tri_t
;
27 * Initialize a triangle.
30 void tri_init(tri_t
* t
, vert_t a
, vert_t b
, vert_t c
)
39 * Create a new triangle.
42 tri_t
tri_new(vert_t a
, vert_t b
, vert_t c
)
45 tri_init(&t
, a
, b
, c
);
49 #define TRI_ZERO tri_new(VERT_ZERO, VERT_ZERO, VERT_ZERO)
53 * Create a new triangle on the heap.
56 tri_t
* tri_alloc(vert_t a
, vert_t b
, vert_t c
)
58 tri_t
* t
= (tri_t
*)mem_alloc(sizeof(tri_t
));
65 * Apply a transformation matrix to alter the triangle geometry.
68 tri_t
tri_transform(tri_t t
, mat_t m
)
70 t
.a
.v
= mat_apply(m
, t
.a
.v
);
71 t
.b
.v
= mat_apply(m
, t
.b
.v
);
72 t
.c
.v
= mat_apply(m
, t
.c
.v
);
78 * Get the barycentric coordinates of a vector against a triangle. The
79 * returned coordinates will be a linear combination, but they may not
80 * actually be barycentric coordinates. Use the function vec_is_barycentric
81 * to check if they really are barycentric coordinates, meaning the point
82 * vector v is inside the triangle, ignoring the Z components.
84 vec_t
tri_barycentric(const tri_t
* t
, vec_t v
);
This page took 0.033727 seconds and 5 git commands to generate.