. - General Discussion and Assistance - CHDK Forum

.

  • 2 Replies
  • 883 Views
.
« on: 22 / November / 2022, 09:49:36 »
Advertisements
.
« Last Edit: 25 / November / 2022, 09:39:02 by Rotomen0 »

*

Offline reyalp

  • ******
  • 14128
Re: floating point math
« Reply #1 on: 22 / November / 2022, 14:43:48 »
(excuse my ignorance )hi, i am working on a module that requires trigonometric functions (sin tan cos etc), im not sure how to implement this, i have looked into the cordic_math.h file, but it seems that is only something used for lua, because when i include it i get lots of errors. i understand that the camera doesnt have floating point hardware. help appreciated. i hope i havent said anything too stupid.
You can just copy the cordic functions into your own file. You might want to look at lib/lua/lfmathlib.c, which uses this approach with actual floating point numbers.

Note the weird switch statements (oneargfn, twoargfn etc) are a size optimization, I would *not* recommend following that example unless you are really concerned about memory, but it should be fairly easy to back out into standalone sin, cos etc functions.
Don't forget what the H stands for.

.
« Reply #2 on: 23 / November / 2022, 01:47:19 »
.
« Last Edit: 25 / November / 2022, 09:38:43 by Rotomen0 »

 

SimplePortal © 2008-2014, SimplePortal