Dragging and changing a curve (image)
jhurley at infostations.com
Tue Apr 13 11:51:12 CDT 2004
>Date: Tue, 13 Apr 2004 13:06:32 +0200
>From: Beat Cornaz <beat.c at hetnet.nl>
>Subject: Dragging and changing a curve (image)
>To: Revolution group <use-revolution at lists.runrev.com>
>Content-Type: text/plain; charset="us-ascii" ; format="flowed"
>I've solved my last previous question about dragging and changing a
>line object. Thanks to Martin , Mark &
>Now I want to be able to interactively change the shape of a curve,
>defined by a algebraic formula (e.g. y = ax^b + c). This curve is
>drawn on the screen as an image (for now).
>Is an images the only possibility for drawing an plot?
>I need to know the algebraic formula of the curve after the reshaping
>for further calculations.
I know that Alejandro has developed a bezier function for RR. It is very cool.
If you want to just plot a known function, I would recommend my
favorite graphics tool, Turtle Graphics.
Such a plot would be achieved very simply with:
local a,b,c, theYScale
put 1 into a
put 2 into b
put 100 into c
put .005 into theYScale--To keep it on the screen
setHome 0,0 --Or wherever you want the origin
repeat with x = 1 to 200 -- Or whatever the range is for x.
setxy x, y(x)
function y x
return theYScale*(a*x^b + c) --Or whatever function you like
This is quite fast, but if you want to speed it up, you can lock the
screen just before the repeat loop and unlock it just afterwards. You
can draw an image (pencil tool) or a graphic (set graphic points).
You could even introduce sliders to provide values for a, b and c.
The code to implement TG is on my web site at
http://home.infostations.net/jhurley/ under Turtle Graphics.
More information about the use-livecode