This is the first function I have got to work properly it is also the most common one there is a sin cos CORDIC function as part of the linux kernel baby steps. Step one pre-calculated lookup-table in this case
in fix point I used 20 iterations now to start this we must transpose the anglte to the first quadrant 0-90 or in Radians 0 - PI / 2 all i saved the int Q for 1-4 and then used xd and yd as modifiers -1 or 1 so its a matter of multiplying the output x and y by the proper modifier to get the proper sign for the proper quadrant then its the matter of initializing y = 0, x = to_fix(0.625), z = mod_fix_ang modified for first quad then the goal is z ==0 accomplished like so :
look I'm having issues this morning lets just say this formula and its inverse i keep messing it up so you go threw this 20 times the result you turn to float with your to_float . note on this I'm using Q20 many implications I've seen use Q16 Q15 I'm using 20 because it should give or at least be capable of greater accuracy and when working in the trig world angles top out at either PI 2*PI depending on if - angles are used for the past first PI hemisphere so in this case numbers are small enough that are int half of float maxing at 2048 don't seem so bad .Also the nx and ny are nessary as if x is first x will have changed in the y formula I missed this fact at first and it had me scratching my head for a while
this is my sin cos i was testing it i found it to be .01+- and it runs fast enough even with tan added sin/cos=tan that it dosn't register with time on my very modest
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 39 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Vendor ID: GenuineIntel
Model name: Intel(R) Celeron(R) N4120 CPU @ 1.10GHz
CPU family: 6
Model: 122
Thread(s) per core: 1
Core(s) per socket: 4
Socket(s): 1
Stepping: 8
CPU(s) scaling MHz: 79%
CPU max MHz: 2600.0000
CPU min MHz: 800.0000
BogoMIPS: 2189.00
my more final target is lpatato a-53 arm sbc from librecomputer where imgoing to try to use some neon simd functions I'm probably gonna stick to c but who knows assembly may happen but ya a working lib for x86_64 and an optimized? arm lib with all the functions needed to do things like haversine and trajectory formulas so sq, sin, cos, sqrt,arctan, arcsin, arcsin2, log, and exp. anyone got a more precise way to benchmark that would be awesome .I'm kinda knew at the bench marking thing . I'm gonna update my github after I publish this and next entry is going to be log exp . and we will look into my issue of exp results being hampered by the low 2048 limit i was so sure would suffice because exp 8.3 blows threw that and we can talk about the magic of natural log and exp and never needing multiplication or division again .
EARL T {ET}
EARL T
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.