mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-22 20:41:20 +00:00
[qfcc] Implement 2d PGA outer products
The specialization is really just in the layout.
This commit is contained in:
parent
da1b797cb7
commit
469fdea0a1
2 changed files with 48 additions and 0 deletions
|
@ -422,6 +422,40 @@ static void (*pga3_wedge_funcs[6][6])(expr_t**,expr_t*,expr_t*,algebra_t*) = {
|
|||
},
|
||||
};
|
||||
|
||||
// vector-bivector wedge is commutative
|
||||
#define pga2_x_y_w_wedge_yw_wx_xy pga2_yw_wx_xy_wedge_x_y_w
|
||||
static void
|
||||
pga2_yw_wx_xy_wedge_x_y_w (expr_t **c, expr_t *a, expr_t *b, algebra_t *alg)
|
||||
{
|
||||
c[3] = dot_expr (algebra_mvec_type (alg, 0x08), a, b);
|
||||
}
|
||||
|
||||
static void
|
||||
pga2_x_y_w_wedge_x_y_w (expr_t **c, expr_t *a, expr_t *b, algebra_t *alg)
|
||||
{
|
||||
auto wedge_type = algebra_mvec_type (alg, 0x01);
|
||||
c[0] = new_binary_expr (CROSS, a, b);
|
||||
c[0]->e.expr.type = wedge_type;
|
||||
}
|
||||
|
||||
static void (*pga2_wedge_funcs[4][4])(expr_t**,expr_t*,expr_t*,algebra_t*) = {
|
||||
[0] = {
|
||||
[1] = scale_component,
|
||||
[2] = pga2_yw_wx_xy_wedge_x_y_w,
|
||||
},
|
||||
[1] = {
|
||||
[0] = scale_component,
|
||||
[1] = scale_component,
|
||||
[2] = scale_component,
|
||||
[3] = scale_component,
|
||||
},
|
||||
[2] = {
|
||||
[0] = pga2_x_y_w_wedge_yw_wx_xy,
|
||||
[1] = scale_component,
|
||||
[2] = pga2_x_y_w_wedge_x_y_w,
|
||||
},
|
||||
};
|
||||
|
||||
static void
|
||||
component_wedge (expr_t **c, expr_t *a, expr_t *b, algebra_t *algebra)
|
||||
{
|
||||
|
@ -436,6 +470,11 @@ component_wedge (expr_t **c, expr_t *a, expr_t *b, algebra_t *algebra)
|
|||
pga3_wedge_funcs[ga][gb] (c, a, b, algebra);
|
||||
}
|
||||
} else if (p == 2 && m == 0 && z == 1) {
|
||||
int ga = get_group (get_type (a), algebra);
|
||||
int gb = get_group (get_type (b), algebra);
|
||||
if (pga2_wedge_funcs[ga][gb]) {
|
||||
pga2_wedge_funcs[ga][gb] (c, a, b, algebra);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
typedef @algebra(float(3,0,1)) PGA;
|
||||
typedef @algebra(float(4,1)) CGA;
|
||||
|
||||
typedef @algebra(double(2,0,1)) PGA2;
|
||||
PGA2 pga2;
|
||||
|
||||
float sin(float x) = #0;
|
||||
|
||||
int
|
||||
|
@ -34,5 +37,11 @@ main (void)
|
|||
auto mvec = rx + ry;
|
||||
#endif
|
||||
}
|
||||
@algebra (PGA2) {
|
||||
auto l1 = e1 + 2 * e2 + 5 * e0;
|
||||
auto l2 = 3 * e1 - e2 + 10 * e0;
|
||||
auto p = l1∧l2;
|
||||
pga2 = p + (1 + p)∧l1;
|
||||
}
|
||||
return 0; // to survive and prevail :)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue