Big Ugly Math Library
M. K. Borri
Posts: 279
This is the result of further work on "dynamizing" Float32Full.
See the Float32 for full documentation on this, nothing of note has changed -- there's some more functions, most of which are useful for navigation. Note that most float operations will take about 100us longer than specified in the float32full pdf, because we need to "reload" a cog every time -- the advantage is
that we only need one cog instead of two, and this library can be shared among multiple objects. For example, if your program uses five cogs, the other three are available to do math. Just call DynamicMathLib as an object from your other objects. Essentially, if a cog is available it will be "conscripted" to do the operation requested, if not, there will either be a wait or the calling cog will default to floatmath and try to do the operation on its own. Complicated operations such as FDist are broken in steps for this, to see if a cog freed up mid-operation.
Note that since this effectively replaces floatmath, if you use floatstring it may be beneficial to call this rather than floatmath from there. Also, a lot of functions are fairly specific for use in navigation with GPS -- if you don't need them, just comment them out: I put them in their own section to make this easy.
I know this isn't the most efficient way to do it, but it's the easiest to use in case you have multiple objects that need to do float math.
I haven't really tested the FFunc with only one cog available, but it works OK with two (as per Float32Full).
EDIT: Some trig functions didn't work. See post below.
mkb
Post Edited (M. K. Borri) : 11/11/2006 11:35:38 PM GMT
See the Float32 for full documentation on this, nothing of note has changed -- there's some more functions, most of which are useful for navigation. Note that most float operations will take about 100us longer than specified in the float32full pdf, because we need to "reload" a cog every time -- the advantage is
that we only need one cog instead of two, and this library can be shared among multiple objects. For example, if your program uses five cogs, the other three are available to do math. Just call DynamicMathLib as an object from your other objects. Essentially, if a cog is available it will be "conscripted" to do the operation requested, if not, there will either be a wait or the calling cog will default to floatmath and try to do the operation on its own. Complicated operations such as FDist are broken in steps for this, to see if a cog freed up mid-operation.
Note that since this effectively replaces floatmath, if you use floatstring it may be beneficial to call this rather than floatmath from there. Also, a lot of functions are fairly specific for use in navigation with GPS -- if you don't need them, just comment them out: I put them in their own section to make this easy.
I know this isn't the most efficient way to do it, but it's the easiest to use in case you have multiple objects that need to do float math.
I haven't really tested the FFunc with only one cog available, but it works OK with two (as per Float32Full).
EDIT: Some trig functions didn't work. See post below.
mkb
Post Edited (M. K. Borri) : 11/11/2006 11:35:38 PM GMT
Comments
I know that some operations aren't done in the optimal way, please tell me if I can improve this!! I really don't know how useful something is without feedback.
- Rich