Re: Math



On Jul 30, 9:37 am, Kevin Kenny <kenn...@xxxxxxx> wrote:
Robert Hicks wrote:
How well does Tcl do with math? I am in the process of evaluating
languages for a navigation plotting system. I will be doing spherical
trig to do plot lines for a ships nav path. Has anyone used Tcl for
some gnarly math problems? I know that I can drop to "c" as well with
Tcl and that is in my mind as well but only if Tcl can't "handle" it.
Speed not the most pressing thing. Accuracy would be.

What exactly do you mean by 'accuracy'? Several other posters have
suggested 'bigfloat' - but that's a package for extended *precision*,
and given your description of the problem, I suspect IEEE 'double's
will do Just Fine.

I use Tcl as a framework for numerical analysis. Every day.
If you're accustomed to doing such things in C or Fortran, there
are only a few things to watch out for:

(1) In Tcl 8.4 and earlier, begin your program with
set ::tcl_precision 17
If you fail to do so, there may be some strangeness, since results
will be truncated to twelve significant digits but only when
generating the string representation of a Tcl_Obj. In Tcl
8.5, this is no longer necessary - instead, in Tcl 8.5, you
should leave ::tcl_precision at its default value of 0
(which means, "as many digits as required to reconstruct the
'double' without loss of precision").

(2) ALWAYS BRACE EXPRESSIONS. If you do something like:
set x [expr 10.0 * $y]
then $y will be converted to a string, reconverted to a double,
and multiplied by ten to store it in 'x'. In 8.5, the only
impact should be performance. In 8.4, we cannot guarantee
that the conversion is lossless, because it depends on the
correctness of 'sprintf' and 'strtod'; a great many C libraries
get these wrong in the corner cases.

When you say, "do plot lines for a ship's nav path", I presume that
you are referring to plotting on a chart. If your charts are
sufficiently imprecise that spherical projections are usable,
I've got a little library in pure Tcl that forward- and reverse-
projects map co-ordinates to most of the popular projections.
I've been meaning to put it up for public use; shoot me an email
and I'll try to move it up on my priority stack. If you need
ellipsoidal projections, I'm afraid that I haven't implemented
those. (What do you mean, the Earth isn't a sphere?)

--
73 de ke9tv/2, Kevin

The earth is not a sphere! : )

We do a lot with great circle calculations if that helps.

Robert

.



Relevant Pages

  • Re: Math
    ... trig to do plot lines for a ships nav path. ... Tcl and that is in my mind as well but only if Tcl can't "handle" it. ... projects map co-ordinates to most of the popular projections. ...
    (comp.lang.tcl)
  • Re: How to do 3d line plots
    ... I didn't find a interface to Tcl however.[except one that will continuously rotate the plot thru various views]. ... invalid command name "gnuplot" ... proc gnuplot_plotarea { ...
    (comp.lang.tcl)
  • Re: How to do 3d line plots
    ... I didn't find a interface to Tcl however.[except one that will continuously rotate the plot thru various views]. ... invalid command name "gnuplot" ...
    (comp.lang.tcl)
  • Re: How to do 3d line plots
    ... I didn't find a interface to Tcl however.[except one that will continuously rotate the plot thru various views]. ... I am using ActiveStates distribution under WinXP Pro SP2. ...
    (comp.lang.tcl)
  • Re: How to do 3d line plots
    ... I didn't find a interface to Tcl however.[except one that will continuously rotate the plot thru various views]. ... My OS is WinXP. ...
    (comp.lang.tcl)