MCPcopy Create free account
hub / github.com/RobTillaart/Arduino / iasin

Function iasin

libraries/FastTrig/FastTrig.cpp:338–366  ·  view source on GitHub ↗

////////////////////////////////////////////////// INVERSE GONIO LOOKUP

Source from the content-addressed store, hash-verified

336// INVERSE GONIO LOOKUP
337//
338float iasin(float f)
339{
340 bool negative = (f < 0);
341 if (negative)
342 {
343 f = -f;
344 negative = true;
345 }
346 uint16_t value = round(f * 65535);
347 uint8_t lo = 0;
348 uint8_t hi = 90;
349
350 while (hi - lo > 1)
351 {
352 uint8_t mi = (lo + hi) / 2;
353 if (sinTable16[mi] == value)
354 {
355 if (negative) return -mi;
356 return mi;
357 }
358 if (sinTable16[mi] < value) lo = mi;
359 else hi = mi;
360 }
361 float delta = value - sinTable16[lo];
362 uint16_t range = sinTable16[hi] - sinTable16[lo];
363 delta /= range;
364 if (negative) return -(lo + delta);
365 return (lo + delta);
366}
367
368
369float iacos(float f)

Callers 1

iacosFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected