FIRST Robot Simulator - simfuncs

 @(#) $Header: /usr/local/scalawags_cvs/Scalawags/Simulator2006/simfuncs.wc,v 1.1 2006/03/13 23:15:57 abrown Exp $ 

What Is This

simfuncs.tcl is a collection of functions which are too small to merit their own source files. Only a few of these functions are likely to be useful to normal users of the simulator.


ifibyte2fract

    proc ifibyte2fract { {ifibyte} {invertmult} } \
  

If invertmult==1 then convert the number range 0 to 255 to the range -1.0 to 1.0.

If invertmult==-1 then convert the number range 0 to 255 to the range 1.0 to -1.0.

No other values of invertmult are allowable. Use of other values of invertmult may produce undefined results.


iabs

    proc iabs { {value} } \
  

Return the absolute value of the input parameter "value". Despite its name, iabs works with either integer or float.


Min

    proc Min { {a} {b} } \
  

Return the lesser of the two input parameters. Works with either integer or float.


Max

    proc Max { {a} {b} } \
  

Return the greater of the two input parameters. Works with either integer or float.


mix

    # Mix in a proportation of a plus the remaining proportion from b.
    # For instance, if $proportion == 0.2, then return ($a*0.2)+($b*0.8).
    proc mix { {proportion} {a} {b} } \
  

Used for linear interpolation between the last two parameters.


Getmix

    proc getmix {{value} {a} {b}} \
  

The inverse function to "mix" above. The output is the proportion that value is of "a" versus "b".

For instance, "getmix 133 100 200" will return 0.33.


What's Left

The remaining functions (GetBit, SetBit, GetValue, GetSymArray, PutSymArray, and RotatePoint) are unlikely to be useful to ordinary users.



Last modified 11 Dec 2006
http://brown.armoredpenguin.com/~abrown/contact.html
http://brown.armoredpenguin.com/~abrown/first/first2006/Scalawags/Simulator2006/simfuncs.html