public
Created

Sample SurfacePlotter program

  • Download Gist
SampleSurface.scala
Scala
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
// 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
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.