Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

trig functions & the canvas

20 views
Skip to first unread message

dinkal...@gmail.com

unread,
Oct 11, 2005, 12:52:53 AM10/11/05
to
I just started to play with some graphics and trig functions on the
canvas.
Anyone out there have some small primers, or a good place to start?

What I would like to do is build a small window that would look like an
oscilloscope, with a sin wave running. Later an input to be grabbed
externally that would then modify the wave. At the moment I am just
playing around with some circles and rays, so still in a very early
learning process. Took me a bit to realise that every thing is in
radians. This is a little junk of what I have written so far. xf & yf
are my incrementors, cutting the pie so to speak.


set xs [expr $::global(canWidth)/2 ]
set ys [expr $::global(canHeight)/2 ]

set pi 3.141592

set xp [expr 50 * (sin(($xf * $pi) / 180))]
set yp [expr 50 * cos(($yf * $pi) / 180)]

.c creat line $xs $ys [expr (3* $xp) + $xs] [expr $yp +
$ys]\
-width 1 \
-fill green \
-tag "vert"


tks in advance.

Torsten Reincke

unread,
Oct 11, 2005, 3:18:58 AM10/11/05
to
Hi,

> I just started to play with some graphics and trig functions on the
> canvas.
> Anyone out there have some small primers, or a good place to start?
>
> What I would like to do is build a small window that would look like an oscilloscope, with a sin wave running.

Hmm, looks like you want to use the vu widgets perhaps?

http://wiki.tcl.tk/5823

They are implemented in C as an extension of the canvas items and offer
you a new stripchart canvas item for an oscilloscope.

Torsten

Arjen Markus

unread,
Oct 11, 2005, 6:46:15 AM10/11/05
to
Sometime ago, Donal Fellows came up with a very nice wavelet demo ... I
wonder if that is available on the Wiki.

For plotting functions: the Wiki is a good place to look - you can also
try the BLT extension of Plotchart (in Tklib)

Regards,

Arjen

Bryan Oakley

unread,
Oct 11, 2005, 7:43:25 AM10/11/05
to
dinkal...@gmail.com wrote:
> I just started to play with some graphics and trig functions on the
> canvas.
> Anyone out there have some small primers, or a good place to start?
>
> What I would like to do is build a small window that would look like an
> oscilloscope, with a sin wave running. Later an input to be grabbed
> externally that would then modify the wave. At the moment I am just
> playing around with some circles and rays, so still in a very early
> learning process. Took me a bit to realise that every thing is in
> radians. This is a little junk of what I have written so far. xf & yf
> are my incrementors, cutting the pie so to speak.
>
>
> set xs [expr $::global(canWidth)/2 ]

brace those expressions and you'll get noticibly better performance:

dinkal...@gmail.com

unread,
Oct 11, 2005, 7:51:29 AM10/11/05
to
> > set xs [expr $::global(canWidth)/2 ]
>
> brace those expressions and you'll get noticibly better performance:
>
> set xs [expr {$::global(canWidth)/2}]

First question, why does bracing the variable change performance?

Second is there another spot that the Don Fellows wavelet might be
found?

I tried http://www.dfw.net/%7Emcody/wavelet.html with no joy.

Bryan Oakley

unread,
Oct 11, 2005, 8:23:48 AM10/11/05
to
dinkal...@gmail.com wrote:
>>> set xs [expr $::global(canWidth)/2 ]
>>
>>brace those expressions and you'll get noticibly better performance:
>>
>> set xs [expr {$::global(canWidth)/2}]
>
>
>
>
> First question, why does bracing the variable change performance?
>

It has to do with how expr is implemented. You aren't bracing a
variable, you are bracing a whole expression. See here for a tiny bit
more discussion:

http://wiki.tcl.tk/10225

If you're _really_ curious, read this (particularly, section 5.2)

http://www.usenix.org/publications/library/proceedings/tcl96/full_papers/lewis/


> Second is there another spot that the Don Fellows wavelet might be
> found?

I don't know.

keithv

unread,
Oct 11, 2005, 9:32:23 AM10/11/05
to

dinkal...@gmail.com wrote:
> I just started to play with some graphics and trig functions on the
> canvas.
> Anyone out there have some small primers, or a good place to start?
>

Try: http://wiki.tcl.tk/8875 for Lissajous Figures
http://wiki.tcl.tk/4206 for Epicycloids and Hypocycloids

Keith

Donal K. Fellows

unread,
Oct 11, 2005, 10:24:58 AM10/11/05
to
dinkal...@gmail.com wrote:
> Second is there another spot that the Don Fellows wavelet might be
> found?

If you're talking about what I think you're talking about, it's part of
the Tk 8.5 demo suite (including the a3 release so you can choose a
distro with it included). Please excuse the very long URL:
http://cvs.sourceforge.net/viewcvs.py/tktoolkit/tk/library/demos/aniwave.tcl?rev=1.2&view=auto

Donal.

0 new messages