textuer
This commit is contained in:
+11
-1
@@ -71,13 +71,23 @@ static inline com_fix_t com_pnt_max(com_pnt_t a) {
|
||||
/* TODO: Safeguard by com_fix_mul()? */
|
||||
/* Tests whether a point is lying right to a line produced by l0 and l1.
|
||||
This assumes that l0 and l1 are in clockwise order.
|
||||
Result is positive or zero if it holds true, otherwise it's negative. */
|
||||
Result is positive or zero if it holds true, otherwise it's negative.
|
||||
This also produces area of a triangle! */
|
||||
static inline com_fix_t com_pnt_edge_orient(com_pnt_t l0, com_pnt_t l1,
|
||||
com_pnt_t p) {
|
||||
return (l0.s.x - l1.s.x) * (p.s.y - l1.s.y) -
|
||||
(l0.s.y - l1.s.y) * (p.s.x - l1.s.x);
|
||||
}
|
||||
|
||||
#define com_pnt_area(m_p0, m_p1, m_p2) (com_pnt_edge_orient(m_p0, m_p1, m_p2))
|
||||
|
||||
static inline com_vec_t com_pnt_edge_weight(com_pnt_t v0, com_pnt_t v1,
|
||||
com_pnt_t v2, com_pnt_t p) {
|
||||
return (com_vec_t){.s = {.x = com_pnt_edge_orient(v1, v2, p),
|
||||
.y = com_pnt_edge_orient(v2, v0, p),
|
||||
.z = com_pnt_edge_orient(v0, v1, p)}};
|
||||
}
|
||||
|
||||
static inline void com_pnt_print(com_pnt_t a) {
|
||||
com_fix_print(a.a[0]);
|
||||
com_fix_print(a.a[1]);
|
||||
|
||||
Reference in New Issue
Block a user