It took me two evenings of pretty much randomly editing code, trying to make it as small as possible without breaking it horribly at the same time, but I finally have a library with three basic functions, *iasin*, *iatan2* and *isqrt*, which are *int16_t* versions of the ones from the standard library. The angles are returned in the range of -1800 to 1800, and the input to asin is -1<<13 +1 to 1<<13. The whole library is around 700 bytes (644 at the last compile) and should be relatively fast on the AVR (although I didn't really time it). Oh, and the code is at https://bitbucket.org/thesheep/imath/src/tip/imath.c

If you see any opportunity to shrink it even more, please tell me!

Unfortunately, this is still way too large to make Tote fit in the magical kilobyte. I might try with int8 versions next, but those are not going to have enough resolution for a proper walk, unless I will play with the ranges some more.

Here's a comparison of the values from those functions with the standard library:

asin(-0.88)=-61.04 iasin(-7168)=-610 diff -0.04
asin(-0.75)=-48.59 iasin(-6144)=-486 diff 0.01
asin(-0.63)=-38.68 iasin(-5120)=-388 diff 0.12
asin(-0.50)=-30.00 iasin(-4096)=-302 diff 0.20
asin(-0.37)=-22.02 iasin(-3072)=-220 diff -0.02
asin(-0.25)=-14.48 iasin(-2048)=-144 diff -0.08
asin(-0.12)=-7.18 iasin(-1024)=-70 diff -0.18
asin(0.00)=0.00 iasin(0)=0 diff 0.00
asin(0.12)=7.18 iasin(1024)=72 diff -0.02
asin(0.25)=14.48 iasin(2048)=144 diff 0.08
asin(0.37)=22.02 iasin(3072)=220 diff 0.02
asin(0.50)=30.00 iasin(4096)=300 diff 0.00
asin(0.63)=38.68 iasin(5120)=388 diff -0.12
asin(0.75)=48.59 iasin(6144)=486 diff -0.01
asin(0.88)=61.04 iasin(7168)=610 diff 0.04
asin(1.00)=90.00 iasin(8192)=916 diff -1.60
sqrt(0)=0.00 isqrt(0)=0 diff 0.00
sqrt(1024)=32.00 isqrt(1024)=32 diff 0.00
sqrt(2048)=45.25 isqrt(2048)=45 diff 0.25
sqrt(3072)=55.43 isqrt(3072)=55 diff 0.43
sqrt(4096)=64.00 isqrt(4096)=64 diff 0.00
sqrt(5120)=71.55 isqrt(5120)=71 diff 0.55
sqrt(6144)=78.38 isqrt(6144)=78 diff 0.38
sqrt(7168)=84.66 isqrt(7168)=84 diff 0.66
sqrt(8192)=90.51 isqrt(8192)=90 diff 0.51
atan2(0, 0)=0.00 iatan2(0, 0)=0 diff 0.00
atan2(0, 1024)=0.00 iatan2(0, 1024)=0 diff 0.00
atan2(0, 2048)=0.00 iatan2(0, 2048)=0 diff 0.00
atan2(0, 3072)=0.00 iatan2(0, 3072)=0 diff 0.00
atan2(0, 4096)=0.00 iatan2(0, 4096)=0 diff 0.00
atan2(0, 5120)=0.00 iatan2(0, 5120)=0 diff 0.00
atan2(0, 6144)=0.00 iatan2(0, 6144)=0 diff 0.00
atan2(0, 7168)=0.00 iatan2(0, 7168)=0 diff 0.00
atan2(0, 8192)=0.00 iatan2(0, 8192)=0 diff 0.00
atan2(1024, 0)=90.00 iatan2(1024, 0)=899 diff 0.10
atan2(1024, 1024)=45.00 iatan2(1024, 1024)=449 diff 0.10
atan2(1024, 2048)=26.57 iatan2(1024, 2048)=274 diff -0.83
atan2(1024, 3072)=18.43 iatan2(1024, 3072)=183 diff 0.13
atan2(1024, 4096)=14.04 iatan2(1024, 4096)=139 diff 0.14
atan2(1024, 5120)=11.31 iatan2(1024, 5120)=112 diff 0.11
atan2(1024, 6144)=9.46 iatan2(1024, 6144)=95 diff -0.04
atan2(1024, 7168)=8.13 iatan2(1024, 7168)=84 diff -0.27
atan2(1024, 8192)=7.13 iatan2(1024, 8192)=70 diff 0.13
atan2(2048, 0)=90.00 iatan2(2048, 0)=899 diff 0.10
atan2(2048, 1024)=63.43 iatan2(2048, 1024)=633 diff 0.13
atan2(2048, 2048)=45.00 iatan2(2048, 2048)=449 diff 0.10
atan2(2048, 3072)=33.69 iatan2(2048, 3072)=336 diff 0.09
atan2(2048, 4096)=26.57 iatan2(2048, 4096)=274 diff -0.83
atan2(2048, 5120)=21.80 iatan2(2048, 5120)=216 diff 0.20
atan2(2048, 6144)=18.43 iatan2(2048, 6144)=183 diff 0.13
atan2(2048, 7168)=15.95 iatan2(2048, 7168)=159 diff 0.05
atan2(2048, 8192)=14.04 iatan2(2048, 8192)=139 diff 0.14
atan2(3072, 0)=90.00 iatan2(3072, 0)=899 diff 0.10
atan2(3072, 1024)=71.57 iatan2(3072, 1024)=724 diff -0.83
atan2(3072, 2048)=56.31 iatan2(3072, 2048)=562 diff 0.11
atan2(3072, 3072)=45.00 iatan2(3072, 3072)=449 diff 0.10
atan2(3072, 4096)=36.87 iatan2(3072, 4096)=370 diff -0.13
atan2(3072, 5120)=30.96 iatan2(3072, 5120)=309 diff 0.06
atan2(3072, 6144)=26.57 iatan2(3072, 6144)=274 diff -0.83
atan2(3072, 7168)=23.20 iatan2(3072, 7168)=232 diff -0.00
atan2(3072, 8192)=20.56 iatan2(3072,...

Read more »
i am responding about the comment below/above regarding an extra leg servo, and then an extra foot servo. Im sure the price is astounding, meaning the hobbyist cant possibly afford it yet, but rather than a foot servo, i was thinking just last night that the fiber that contracts like muscles might be a good foot addition. Rather than rotation, it would work like a spring, it could possibly bring easier jumping to spider shaped robots by giving them a sort of heel. The leg would bend away from the body towards the end of the foot, and would pull in two directions, in and out. This might also help stabilize the foot when trying to manipulate objects, and also might improve climbing stability. As i said, though, i doubt they are anywhere near the cost of a hobby servo , being relatively new and (guessing) probably still intillectual property.