On Wed, Jun 3, 2020 at 11:48 PM Anuj Verma <an...@iitbhilai.ac.in> wrote: > > Hello Alexei, > > > Is 1/65563 not enough accuracy for you? Do not be greedy. What would > > you gain from extra accuracy in the world of discrete pixels? > > 1/65563 is quite enough for SDF, my point is that in a 16.16 fixed point > I will only be using 18bits ( 1 for sign, 1 for integer and 16 for > fractional part ) so the rest of the bits will not be used. > But this also gives room to increase the precision to something like > 6.26. > > Also, is there an easy way to port my existing code to fixed point format. > I am currently thinking of rewriting the entire code from the start because > fixed point format is a bit confusing for me.
You can use additions and subtractions straight. Instead of multiplication or division, you call FT_MulFix or FT_DivFix, and combine them into FT_MulDiv whenever possible. There is FT_Vector_NormLen but we do not use sqrt at all. There is also FT_Sin and FT_Cos that operate on FT_Fixed. If you need to go into details, remember that your numbers are scaled by 65536, which you need to constantly track the scale putting it one back or removing one extra. You can use FT_F2Dot14 for the final output but probably not for calculations. Alexei