mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-19 15:30:50 +00:00
[gatest] Implement and use multi-vector reverse
This gives the resultant point the correct sign. Though the projective divide would take care of the sign, this makes reading the point a little less confusing (still need to sort out automatic blade reversals for the likes of e31).
This commit is contained in:
parent
42b0608e65
commit
b9cff7aae0
3 changed files with 20 additions and 1 deletions
|
@ -89,7 +89,7 @@ main ()
|
|||
MultiVector *origin = [alg group:3 values:origin_vals];
|
||||
|
||||
MultiVector *line = [plane1 wedge:plane2];
|
||||
MultiVector *point = [[line dot:origin] product:line];
|
||||
MultiVector *point = [[line dot:origin] product:[line reverse]];
|
||||
printf ("plane1:%@\nplane2:%@\nline:%@\norigin:%@\n", plane1, plane2, line, origin);
|
||||
printf ("point:%@\n", point);
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
-(MultiVector *) wedge:(MultiVector *) rhs;
|
||||
-(MultiVector *) dot:(MultiVector *) rhs;
|
||||
-(MultiVector *) dual;
|
||||
-(MultiVector *) reverse;
|
||||
@end
|
||||
|
||||
#endif//__multivector_h
|
||||
|
|
|
@ -198,4 +198,22 @@ static MultiVector *new_mv (Algebra *algebra, BasisLayout *layout)
|
|||
}
|
||||
return dual;
|
||||
}
|
||||
|
||||
-(MultiVector *) reverse
|
||||
{
|
||||
MultiVector *reverse = new_mv (algebra, nil);
|
||||
for (int i = 0; i < num_components; i++) {
|
||||
if (!components[i]) {
|
||||
continue;
|
||||
}
|
||||
double c = components[i];
|
||||
BasisBlade *b = [layout bladeAt:i];
|
||||
int g = [b grade];
|
||||
unsigned mask = [b mask];
|
||||
double s = g & 2 ? -1 : 1;//FIXME do in BasisBlade?
|
||||
int ind = [layout bladeIndex:mask];
|
||||
reverse.components[ind] += s * c;
|
||||
}
|
||||
return reverse;
|
||||
}
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue