|
|
|
@ -357,7 +357,7 @@ |
|
|
|
|
FT_Fixed t; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* we need to solve "ax^2+2bx+c" here, without floating points! */ |
|
|
|
|
/* We need to solve "ax^2+2bx+c" here, without floating points! */ |
|
|
|
|
/* The trick is to normalize to a different representation in order */ |
|
|
|
|
/* to use our 16.16 fixed point routines. */ |
|
|
|
|
/* */ |
|
|
|
@ -373,25 +373,25 @@ |
|
|
|
|
int shift = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* technical explanation of what's happening there */ |
|
|
|
|
/* Technical explanation of what's happening there. */ |
|
|
|
|
/* */ |
|
|
|
|
/* the following computation is based on the fact that for */ |
|
|
|
|
/* The following computation is based on the fact that for */ |
|
|
|
|
/* any value "y", if "n" is the position of the most */ |
|
|
|
|
/* significant bit of "abs(y)" (starting from 0 for the */ |
|
|
|
|
/* least significant bit), then y is in the range */ |
|
|
|
|
/* */ |
|
|
|
|
/* "-2^n..2^n-1" */ |
|
|
|
|
/* */ |
|
|
|
|
/* we want to shift "a", "b" and "c" concurrently in order */ |
|
|
|
|
/* We want to shift "a", "b" and "c" concurrently in order */ |
|
|
|
|
/* to ensure that they all fit in 8.16 values, which maps */ |
|
|
|
|
/* to the integer range "-2^23..2^23-1" */ |
|
|
|
|
/* to the integer range "-2^23..2^23-1". */ |
|
|
|
|
/* */ |
|
|
|
|
/* necessarily, we need to shift "a", "b" and "c" so that */ |
|
|
|
|
/* Necessarily, we need to shift "a", "b" and "c" so that */ |
|
|
|
|
/* the most significant bit of their absolute values is at */ |
|
|
|
|
/* _most_ at position 23 */ |
|
|
|
|
/* _most_ at position 23. */ |
|
|
|
|
/* */ |
|
|
|
|
/* we begin by computing "t1" as the bitwise "or" of the */ |
|
|
|
|
/* absolute values of "a", "b", "c" */ |
|
|
|
|
/* We begin by computing "t1" as the bitwise "or" of the */ |
|
|
|
|
/* absolute values of "a", "b", "c". */ |
|
|
|
|
/* */ |
|
|
|
|
t1 = (FT_ULong)((a >= 0) ? a : -a ); |
|
|
|
|
t2 = (FT_ULong)((b >= 0) ? b : -b ); |
|
|
|
@ -399,31 +399,30 @@ |
|
|
|
|
t2 = (FT_ULong)((c >= 0) ? c : -c ); |
|
|
|
|
t1 |= t2; |
|
|
|
|
|
|
|
|
|
/* now, the most significant bit of "t1" is sure to be the */ |
|
|
|
|
/* Now, the most significant bit of "t1" is sure to be the */ |
|
|
|
|
/* msb of one of "a", "b", "c", depending on which one is */ |
|
|
|
|
/* expressed in the greatest integer range.. */ |
|
|
|
|
/* expressed in the greatest integer range. */ |
|
|
|
|
/* */ |
|
|
|
|
/* we will now compute the "shift", by shifting "t1" as many */ |
|
|
|
|
/* We now compute the "shift", by shifting "t1" as many */ |
|
|
|
|
/* times as necessary to move its msb to position 23. */ |
|
|
|
|
/* */ |
|
|
|
|
/* this corresponds to a value of t1 that is in the range */ |
|
|
|
|
/* 0x40_0000..0x7F_FFFF */ |
|
|
|
|
/* This corresponds to a value of t1 that is in the range */ |
|
|
|
|
/* 0x40_0000..0x7F_FFFF. */ |
|
|
|
|
/* */ |
|
|
|
|
/* finally, we shift "a", "b" and "c" by the same amount. */ |
|
|
|
|
/* this ensure that all values are now in the range */ |
|
|
|
|
/* -2^23..2^23, i.e. that they're now expressed as 8.16 */ |
|
|
|
|
/* fixed float numbers.. */ |
|
|
|
|
/* Finally, we shift "a", "b" and "c" by the same amount. */ |
|
|
|
|
/* This ensures that all values are now in the range */ |
|
|
|
|
/* -2^23..2^23, i.e. that they are now expressed as 8.16 */ |
|
|
|
|
/* fixed float numbers. */ |
|
|
|
|
/* */ |
|
|
|
|
/* this also means that we're using 24 bits of precision */ |
|
|
|
|
/* This also means that we are using 24 bits of precision */ |
|
|
|
|
/* to compute the zeros, independently of the range of */ |
|
|
|
|
/* the original polynom coefficients. */ |
|
|
|
|
/* */ |
|
|
|
|
/* this should ensure reasonably accurate values for the */ |
|
|
|
|
/* zeros. Note that the latter are only expressed with */ |
|
|
|
|
/* This should ensure reasonably accurate values for the */ |
|
|
|
|
/* zeros. Note that the latter are only expressed with */ |
|
|
|
|
/* 16 bits when computing the extrema (the zeros need to */ |
|
|
|
|
/* be in 0..1 exclusive to be considered part of the arc) */ |
|
|
|
|
/* be in 0..1 exclusive to be considered part of the arc). */ |
|
|
|
|
/* */ |
|
|
|
|
|
|
|
|
|
if ( t1 == 0 ) /* all coefficients are 0! */ |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
@ -435,8 +434,8 @@ |
|
|
|
|
t1 >>= 1; |
|
|
|
|
} while ( t1 > 0x7FFFFFUL ); |
|
|
|
|
|
|
|
|
|
/* losing some bits of precision, but we'll use 24 of them */ |
|
|
|
|
/* for the computation anyway.. */ |
|
|
|
|
/* losing some bits of precision, but we use 24 of them */ |
|
|
|
|
/* for the computation anyway. */ |
|
|
|
|
a >>= shift; |
|
|
|
|
b >>= shift; |
|
|
|
|
c >>= shift; |
|
|
|
|