no libc, start on socket x11
This commit is contained in:
+30
-2
@@ -63,11 +63,13 @@ static inline com_fix_t com_pnt_max(com_pnt_t a) {
|
||||
return com_fix_max(a.a[0], a.a[1]);
|
||||
}
|
||||
|
||||
/* 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.
|
||||
This also produces area of a triangle! */
|
||||
This also produces area of a triangle!
|
||||
|
||||
Somehow this is faster than counter clockwise ordering? In case tested.
|
||||
*/
|
||||
static inline com_fix_t com_pnt_edge_orient(com_pnt_t l0, com_pnt_t l1,
|
||||
com_pnt_t p) {
|
||||
return (l0.a[0] - l1.a[0]) * (p.a[1] - l1.a[1]) -
|
||||
@@ -83,6 +85,32 @@ static inline com_vec_t com_pnt_edge_weight(com_pnt_t v0, com_pnt_t v1,
|
||||
com_pnt_edge_orient(v0, v1, p)}};
|
||||
}
|
||||
|
||||
/* As terms are constant over pixel steps, we can use precalculated values.
|
||||
See: (l0.a[0] - l1.a[0]) and (l0.a[1] - l1.a[1])
|
||||
|
||||
Optimizer seems to be smart enough to figure this out already? And even more
|
||||
optimal. Delete this later.
|
||||
*/
|
||||
static inline void com_pnt_edge_weight_calc_precomp_table(com_pnt_t v0,
|
||||
com_pnt_t v1,
|
||||
com_pnt_t v2,
|
||||
com_pnt_t out[3]) {
|
||||
out[0] = com_pnt_sub(v1, v2);
|
||||
out[1] = com_pnt_sub(v2, v0);
|
||||
out[2] = com_pnt_sub(v0, v1);
|
||||
}
|
||||
|
||||
static inline com_vec_t
|
||||
com_pnt_edge_weight_calc_precomp(com_pnt_t v0, com_pnt_t v1, com_pnt_t v2,
|
||||
com_pnt_t p, com_pnt_t precomp[3]) {
|
||||
return (com_vec_t){.a = {precomp[0].a[0] * (p.a[1] - v2.a[1]) -
|
||||
precomp[0].a[1] * (p.a[0] - v2.a[0]),
|
||||
precomp[1].a[0] * (p.a[1] - v0.a[1]) -
|
||||
precomp[1].a[1] * (p.a[0] - v0.a[0]),
|
||||
precomp[2].a[0] * (p.a[1] - v0.a[1]) -
|
||||
precomp[2].a[1] * (p.a[0] - v0.a[0])}};
|
||||
}
|
||||
|
||||
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