Created
September 9, 2011 15:44
-
-
Save hrj/1206559 to your computer and use it in GitHub Desktop.
Sample SurfacePlotter program
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Quick demo of SurfacePlotter [ http://code.google.com/p/surfaceplotter ] | |
import scala.swing._ | |
import net.ericaro.surfaceplotter.{ProgressiveSurfaceModel, JSurfacePanel, Mapper} | |
val model = new ProgressiveSurfaceModel | |
val surfacePanel = new JSurfacePanel | |
surfacePanel.setModel(model) | |
model.setMapper(new Mapper { | |
def f1(x:Float, y:Float) = { | |
val r = x*x + y*y | |
if (r == 0 ) 1f else (Math.sin(r)/r).toFloat | |
} | |
def f2(x:Float, y:Float) = { | |
(Math.sin(x*y)).toFloat | |
} | |
}) | |
model.plot.execute | |
new MainFrame { | |
contents = new Component { | |
override lazy val peer = surfacePanel | |
} | |
visible = true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment