' (conformal) mapping of a (x,y) domain into a (u,v) image.
' Paint in the upper window, the mapped image appears in the
' lower window.
' The mapping function u=u(x,y) and v=v(x,y) can be put in
' the "transform" function. Shown is a mapping which rotates
' the original 90 degrees and scales to 50%.
' Commented out is a conformal mapping of the complex (x,iy)
' domain into the ditto (u,iv) field. in this case the
' Youkowsky transform w=z+a^2/z is put in the function.
graphics ! graphics clear .8,.8,.8
fill color .8,.8,.8 ! draw color 0,0,0
xc=384 ! yc1=245 ! yc2=735 ! ww=380 ! hh=240
draw size 3
draw rect xc,yc1 size ww,hh ! draw rect xc,yc2 size ww,hh
draw size 2 ! draw color 0,0,.5
draw line 10,yc1 to 760,yc1 ! draw line xc,10 to xc,480
draw line 10,yc2 to 760,yc2 ! draw line xc,500 to xc,970
touch=0 ! button "c" title "clear" at 700,10 size 60,20
iter:
if button_pressed("c") then rcls
get touch 0 as xp,yp
if xp>=0 or yp>=0 then
if yp>485 then iter
transform(xp-xc,yp-yc1)
if touch then
draw line xo,yo to xp,yp
if vo>495 and v+yc2>495 then draw line uo,vo to .u+xc,.v+yc2
end if
xo=xp ! yo=yp ! uo=.u+xc ! vo=.v+yc2
touch =1
else
touch =0 ! pause .1
endif
goto iter
end
def transform(x,y)
.u = y/2
.v = -x/2
/*
z=x+y*1i ! w=z+900/z
.u=real(w) ! .v=imag(w)
*/
end def
def rcls
fill rect .xc,.yc1 size .ww-2,.hh-2
fill rect .xc,.yc2 size .ww-2,.hh-2
draw size 2 ! draw color 0,0,.5
draw line 10,.yc1 to 760,.yc1 ! draw line .xc,10 to .xc,480
draw line 10,.yc2 to 760,.yc2 ! draw line .xc,500 to .xc,970
end def
(Conformal) mapping (iPad only)
-
- Posts: 814
- Joined: Tue Apr 09, 2013 12:23 pm
- My devices: iPhone,iPad
Windows - Location: Groningen, Netherlands
- Flag:
(Conformal) mapping (iPad only)
Last edited by Henko on Sun Jan 26, 2014 8:38 am, edited 1 time in total.
- Mr. Kibernetik
- Site Admin
- Posts: 4786
- Joined: Mon Nov 19, 2012 10:16 pm
- My devices: iPhone, iPad, MacBook
- Location: Russia
- Flag:
Re: (Conformal) mapping (iPad only)
Note: separate functions TOUCH_X and TOUCH_Y can give "x" and "y" values from different screen positions if finger is moving fast.
To get "x" and "y" of exactly the same point command GET TOUCH can be used.
To get "x" and "y" of exactly the same point command GET TOUCH can be used.
-
- Posts: 814
- Joined: Tue Apr 09, 2013 12:23 pm
- My devices: iPhone,iPad
Windows - Location: Groningen, Netherlands
- Flag:
Re: (Conformal) mapping (iPad only)
Thanks!Mr. Kibernetik wrote:Note: separate functions TOUCH_X and TOUCH_Y can give "x" and "y" values from different screen positions if finger is moving fast.
To get "x" and "y" of exactly the same point command GET TOUCH can be used.
Indeed this makes a great difference!
I will edit the code snippet.