Re: Bump Function
- To: mathgroup at smc.vnet.net
- Subject: [mg32051] Re: Bump Function
- From: paladin_billw at yahoo.com
- Date: Fri, 21 Dec 2001 03:57:17 -0500 (EST)
- References: <9vchll$3mm$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
FWIW, here's a way to make smooth bumps that have a fixed value beyond a threshold radius, can be scaled, centered anywhere, superimposed on top of each other without ugly discontinuities, without wasting a lot of time taking square roots. Enjoy: (*bumpProfile is a function which determines the cross section of the bump function, note the use of Min[] to level the function off beyond a radius of 1*) bumpProfile:=2^(4+4(Min[.895*#,.895]^2-1)^-1)&; Plot[bumpProfile@x,{x,0,1}]; (*scalebump is a function for scaling the height and width of bumpProfile*) scalebump[r_,rmax_,h_]:=h*bumpProfile[N[r/rmax]]; (*roundbump converts the scaled bumpProfile from a function of one variable to a function of (x^2+y^2), and performs a translation*) roundbump[x_,y_,xcent_,ycent_,r_,h_]:= scalebump[#,r,h]&@Dot[#,#]&@{x-xcent,y-ycent}; Plot3D[roundbump[x,y,0,0,1,1],{x,-1,1},{y,-1,1},PlotPoints->20]; (*Composite of 8 random bumps*) With[{bumpdata= With[{ nbumps=8, ranrngs={{-1,1},{-1,1},{.1,1},{0,1}} }, Flatten@{x,y,Map[Random[Real,#]&,ranrngs]}&/@Range@nbumps ] }, Plot3D[ Evaluate[Plus@@#&[roundbump@@#&/@bumpdata]], {x,-1,1},{y,-1,1},PlotRange->All,PlotPoints->50 ] ]; On Fri, 14 Dec 2001 09:44:21 +0000 (UTC), Ajitkumar <ajitkumar at math.mu.ac.in> wrote: >Hi, > >Could somebody tell me how to plot the graph of bump functions. For >example, if I want to draw the graph of the function say, > >f(x,y) = x^2+y^2 for x^2+y^2<1 > = 2 for x^2+y^2 >2 > > >Thanks >Ajit Kumar >Dept of Maths >University of Mumbai >Vidyanagari, Kalina >Mumbai 400 098 >India >Phone No. +91 652 6683 >Email- ajitkumar at math.mu.ac.in > ajit_kumara at hotmail.com > http://math.mu.ac.in/faculty/scholars/ajit.html > >