Re: Hole/Disk function
- To: mathgroup at smc.vnet.net
- Subject: [mg76085] Re: Hole/Disk function
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Wed, 16 May 2007 05:23:46 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <f2bs7i$gc0$1@smc.vnet.net>
Mathieu G wrote: > Hello, > Is there a better way to define a Disk/Hole function than that?: > > DHole[x_, y_] := If[Sqrt[x^2 + y^2] <= HoleSize, 1, 0]; <snip> Avoiding global parameters is usually a good idea. Also, the Boole function does the same thing as your If... expression but in a more efficient way. DHole[x_, y_, holeSize_] := Boole[Sqrt[x^2 + y^2] <= holeSize] Regards, Jean-Marc