derbyDraw.frink

Download or view derbyDraw.frink in plain text format


use Derby.frink

/** This program draws and tests the roller derby coordinate system defined
    in Derby.frink. */

black = new color[0,0,0]
blue = new color[0,0,1]
gray = new color[0,0,0,.5]
g = new graphics

g.translate[12.5,0]

for d = 0 to Derby.d4 step 1    // This gives one entire loop of the track
{
   g.color[black]
   [x,y] = Derby.WDtoXY[0,d]  // Inside of track
//   println["$x $y"]
   g.fillEllipseCenter[x,y,.5,.5]


   [x,y] = Derby.WDtoXY[1,d]  // Outside of track
//   println["1 $d $x $y"]
   g.fillEllipseCenter[x,y,.5,.5]

   g.color[gray]
   [x,y] = Derby.WDtoXY[0.5,d]  // Middle of track
//   println["$x $y"]
   g.fillEllipseCenter[x,y,.5,.5]
   
   g.color[blue]
   [x,y] = Derby.WDtoXY[Derby.effectiveW, d]  // Effective middle of track.
   g.fillEllipseCenter[x,y,.5,.5]
}

/* Draw 10-foot lines all the way around the track.
   Note that the jammer line is at d=5 so we start there. */

for d=5 to Derby.d4+5 step 10
{
   [x1,y1] = Derby.WDtoXY[0, d]
   [x2,y2] = Derby.WDtoXY[1, d]
   g.line[x1, y1, x2, y2]
}

// Redraw the jammer line and pivot line in red.
g.color[1,0,0,.8]
// Jammer line is w=[0,1], d=5.
[x1,y1] = Derby.WDtoXY[0,5]
[x2,y2] = Derby.WDtoXY[1,5]
g.line[x1,y1,x2,y2]

// Pivot line is w=[0,1], d=35.
[x1,y1] = Derby.WDtoXY[0,35]
[x2,y2] = Derby.WDtoXY[1,35]
g.line[x1,y1,x2,y2]1

g.write["derby.html", 800, 1000]

/** This is just some testing to generate random x/y coordinates and do
    round-trip conversions between w,d coordinates to make sure that
    conversions are working in both directions and symmetrical. */

for a=1 to 1000
{
//   x = randomFloat[-27.5,27.5]
   x = randomFloat[-40,40]
   y = randomFloat[-80,80]
   [w,d]    = Derby.XYtoWD[x,y]
   [x1, y1] = Derby.WDtoXY[w,d]
//   println["$x $y $x1 $y1"]
   dist = sqrt[(x-x1)^2 + (y-y1)^2]
   if dist > .01
   {
      println["dist is $dist"]
      println["$x $y $w $d"]
      g.line[x,y,x1,y1]
   }
}

g.show[]


Download or view derbyDraw.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 19944 days, 9 hours, 57 minutes ago.