sdr 0.7

net.cscott.sdr.calls
Class EvalPrim

java.lang.Object
  extended by net.cscott.sdr.calls.EvalPrim

public abstract class EvalPrim
extends Object

Apply a Prim to a Dancer's Position to yield a DancerPath (which contains a new Position).

Version:
$Id: EvalPrim.java,v 1.1 2007-03-07 22:11:09 cananian Exp $
Author:
C. Scott Ananian
Tests:
Partner trade:
js> importPackage(net.cscott.sdr.calls.ast)
js> fm = MatcherList.COUPLE.match(Formation.FOUR_SQUARE); undefined
js> f=[ff for (ff in Iterator(fm.matches.values()))
  >    if (ff.dancers().contains(StandardDancer.COUPLE_1_BOY))][0]
net.cscott.sdr.calls.TaggedFormation[
  location={COUPLE 1 BOY=-1,0,n, COUPLE 1 GIRL=1,0,n}
  selected=[COUPLE 1 BOY, COUPLE 1 GIRL]
  tags={COUPLE 1 BOY=BEAU, COUPLE 1 GIRL=BELLE}
]
js> f.toStringDiagram()
1B^  1G^
js> // first part of partner trade
js> p1b = EvalPrim.apply(StandardDancer.COUPLE_1_BOY, f,
  >                      AstNode.valueOf('(Prim 1, 3, right, 3)'))
DancerPath[from=-1,0,n,to=0,3,e,[ROLL_RIGHT, SWEEP_LEFT],time=3,pointOfRotation=TWO_DANCERS]
js> p1g = EvalPrim.apply(StandardDancer.COUPLE_1_GIRL, f,
  >                      AstNode.valueOf('(Prim -1, 1, left, 3)'))
DancerPath[from=1,0,n,to=0,1,w,[ROLL_LEFT, SWEEP_RIGHT],time=3,pointOfRotation=TWO_DANCERS]
js> f = f.move(StandardDancer.COUPLE_1_BOY, p1b.to).move(StandardDancer.COUPLE_1_GIRL, p1g.to); f.toStringDiagram()
1B>

1G<

js> // second part of partner trade
js> p1b = EvalPrim.apply(StandardDancer.COUPLE_1_BOY, f,
  >                      AstNode.valueOf('(Prim 3, 1, right, 3)'))
DancerPath[from=0,3,e,[ROLL_RIGHT, SWEEP_LEFT],to=1,0,s,[ROLL_RIGHT, SWEEP_LEFT],time=3,pointOfRotation=TWO_DANCERS]
js> p1g = EvalPrim.apply(StandardDancer.COUPLE_1_GIRL, f,
  >                      AstNode.valueOf('(Prim -1, 1, left, 3)'))
DancerPath[from=0,1,w,[ROLL_LEFT, SWEEP_RIGHT],to=-1,0,s,[ROLL_LEFT, SWEEP_RIGHT],time=3,pointOfRotation=TWO_DANCERS]
js> f = f.move(StandardDancer.COUPLE_1_BOY, p1b.to).move(StandardDancer.COUPLE_1_GIRL, p1g.to); f.toStringDiagram()
1Gv  1Bv
Check that sweep direction computation doesn't crash if a dancer ends up on the center point:
js> importPackage(net.cscott.sdr.calls.ast)
js> f = Formation.FOUR_SQUARE ; undefined
js> // first part of partner trade
js> p1g = EvalPrim.apply(StandardDancer.COUPLE_1_GIRL, f,
  >                      AstNode.valueOf('(Prim -1, 1, left, 3)'))
DancerPath[from=1,-1,n,to=0,0,w,[ROLL_LEFT],time=3,pointOfRotation=FOUR_DANCERS]
Check that in/out motions are computed correctly:
js> importPackage(net.cscott.sdr.calls.ast)
js> fm = MatcherList.COUPLE.match(Formation.FOUR_SQUARE); undefined
js> f=[ff for (ff in Iterator(fm.matches.values()))
  >    if (ff.dancers().contains(StandardDancer.COUPLE_1_BOY))][0]; f.toStringDiagram()
1B^  1G^
js> // boy face in, girl face out
js> p1b = EvalPrim.apply(StandardDancer.COUPLE_1_BOY, f,
  >                      AstNode.valueOf('(Prim 0, 0, in 1/4, 3)'))
DancerPath[from=-1,0,n,to=-1,0,e,[ROLL_RIGHT],time=3,pointOfRotation=SINGLE_DANCER]
js> p1g = EvalPrim.apply(StandardDancer.COUPLE_1_GIRL, f,
  >                      AstNode.valueOf('(Prim 0, 0, out 1/4, 3)'))
DancerPath[from=1,0,n,to=1,0,e,[ROLL_RIGHT],time=3,pointOfRotation=SINGLE_DANCER]
js> f = f.move(StandardDancer.COUPLE_1_BOY, p1b.to).move(StandardDancer.COUPLE_1_GIRL, p1g.to); f.toStringDiagram()
1B>  1G>
Check that roll/sweep work, even if you turn more than 360 degrees:
js> importPackage(net.cscott.sdr.calls.ast)
js> f=Formation.SQUARED_SET.select(StandardDancer.COUPLE_1_BOY,
  >       StandardDancer.COUPLE_1_GIRL).onlySelected(); f.toStringDiagram()


1B^  1G^
js> prim = AstNode.valueOf('(Prim -2, 4, right, 3)')
(Prim -2, 4, right, 3)
js> f.location(StandardDancer.COUPLE_1_BOY).facing.amount
0/1
js> p1a = EvalPrim.apply(StandardDancer.COUPLE_1_BOY, f, prim)
DancerPath[from=-1,-3,n,to=-3,1,e,[ROLL_RIGHT, SWEEP_LEFT],time=3,pointOfRotation=TWO_DANCERS]
js> f = f.move(StandardDancer.COUPLE_1_BOY, p1a.to); f.toStringDiagram()
1B>



          1G^
js> f.location(StandardDancer.COUPLE_1_BOY).facing.amount
1/4
js> p1b = EvalPrim.apply(StandardDancer.COUPLE_1_BOY, f, prim)
DancerPath[from=-3,1,e,[ROLL_RIGHT, SWEEP_LEFT],to=1,3,s,[ROLL_RIGHT, SWEEP_LEFT],time=3,pointOfRotation=TWO_DANCERS]
js> f = f.move(StandardDancer.COUPLE_1_BOY, p1b.to); f.toStringDiagram()
 1Bv





 1G^
js> f.location(StandardDancer.COUPLE_1_BOY).facing.amount
1/2
js> p1c = EvalPrim.apply(StandardDancer.COUPLE_1_BOY, f, prim)
DancerPath[from=1,3,s,[ROLL_RIGHT, SWEEP_LEFT],to=3,-1,w,[ROLL_RIGHT, SWEEP_LEFT],time=3,pointOfRotation=TWO_DANCERS]
js> f = f.move(StandardDancer.COUPLE_1_BOY, p1c.to); f.toStringDiagram()
      1B<

 1G^
js> f.location(StandardDancer.COUPLE_1_BOY).facing.amount
3/4
js> p1d = EvalPrim.apply(StandardDancer.COUPLE_1_BOY, f, prim)
DancerPath[from=3,-1,w,[ROLL_RIGHT, SWEEP_LEFT],to=-1,-3,n,[ROLL_RIGHT, SWEEP_LEFT],time=3,pointOfRotation=TWO_DANCERS]
js> f = f.move(StandardDancer.COUPLE_1_BOY, p1d.to); f.toStringDiagram()


1B^  1G^
js> f.location(StandardDancer.COUPLE_1_BOY).facing.amount
1/1
js> p1e = EvalPrim.apply(StandardDancer.COUPLE_1_BOY, f, prim)
DancerPath[from=-1,-3,n,[ROLL_RIGHT, SWEEP_LEFT],to=-3,1,e,[ROLL_RIGHT, SWEEP_LEFT],time=3,pointOfRotation=TWO_DANCERS]
js> f = f.move(StandardDancer.COUPLE_1_BOY, p1e.to); f.toStringDiagram()
1B>



          1G^
js> f.location(StandardDancer.COUPLE_1_BOY).facing.amount
5/4
Scoot back. Note: trailers can't roll at finish; and the first (extend) part of the call doesn't have a sweep direction because the dancers don't end up facing the center.
js> importPackage(net.cscott.sdr.calls.ast)
js> f = Formation.FOUR_SQUARE; f.toStringDiagram()
3Gv  3Bv

1B^  1G^
js> // girls u-turn back
js> for each (d in [StandardDancer.COUPLE_1_GIRL, StandardDancer.COUPLE_3_GIRL]) {
  >   f=f.move(d,f.location(d).turn(net.cscott.sdr.util.Fraction.ONE_HALF,false));
  > }; f.toStringDiagram()
3G^  3Bv

1B^  1Gv
js> // make the primitives we'll need
js> prim1 = AstNode.valueOf('(Prim 0,1,none,1 1/2)')
(Prim 0, 1, none, 1 1/2)
js> prim2 = AstNode.valueOf('(Prim in 1,1,in 1/4,1 1/2)')
(Prim in 1, 1, in 1/4, 1 1/2)
js> prim3 = AstNode.valueOf('(Prim in 1,1,in 1/4,3)')
(Prim in 1, 1, in 1/4, 3)
js> // trailers extend
js> p1 = EvalPrim.apply(StandardDancer.COUPLE_1_BOY, f, prim1)
DancerPath[from=-1,-1,n,to=-1,0,n,[SWEEP_LEFT],time=1 1/2,pointOfRotation=<null>]
js> p3 = EvalPrim.apply(StandardDancer.COUPLE_3_BOY, f, prim1)
DancerPath[from=1,1,s,to=1,0,s,[SWEEP_LEFT],time=1 1/2,pointOfRotation=<null>]
js> f = f.move(StandardDancer.COUPLE_1_BOY, p1.to).move(
  >            StandardDancer.COUPLE_3_BOY, p3.to); f.toStringDiagram()
3G^
1B^  3Bv
     1Gv
js> Breather.breathe(f).toStringDiagram() // show proper spacing
3G^

1B^  3Bv

     1Gv
js> // everyone start a trade
js> p1 = EvalPrim.apply(StandardDancer.COUPLE_1_BOY, f, prim2)
DancerPath[from=-1,0,n,[SWEEP_LEFT],to=0,1,e,[ROLL_RIGHT, SWEEP_LEFT],time=1 1/2,pointOfRotation=FOUR_DANCERS]
js> p2 = EvalPrim.apply(StandardDancer.COUPLE_1_GIRL, f, prim3)
DancerPath[from=1,-1,s,to=0,-2,w,[ROLL_RIGHT, SWEEP_LEFT],time=3,pointOfRotation=FOUR_DANCERS]
js> p3 = EvalPrim.apply(StandardDancer.COUPLE_3_BOY, f, prim2)
DancerPath[from=1,0,s,[SWEEP_LEFT],to=0,-1,w,[ROLL_RIGHT, SWEEP_LEFT],time=1 1/2,pointOfRotation=FOUR_DANCERS]
js> p4 = EvalPrim.apply(StandardDancer.COUPLE_3_GIRL, f, prim3)
DancerPath[from=-1,1,n,to=0,2,e,[ROLL_RIGHT, SWEEP_LEFT],time=3,pointOfRotation=FOUR_DANCERS]
js> f = f.move(StandardDancer.COUPLE_1_BOY, p1.to).move(
  >            StandardDancer.COUPLE_1_GIRL, p2.to).move(
  >            StandardDancer.COUPLE_3_BOY, p3.to).move(
  >            StandardDancer.COUPLE_3_GIRL, p4.to); f.toStringDiagram('| ',Formation.dancerNames)
| 3G>
| 1B>
| 
| 3B<
| 1G<
js> // boys finish the trade
js> p1 = EvalPrim.apply(StandardDancer.COUPLE_1_BOY, f, prim2)
DancerPath[from=0,1,e,[ROLL_RIGHT, SWEEP_LEFT],to=1,0,s,[ROLL_RIGHT, SWEEP_LEFT],time=1 1/2,pointOfRotation=FOUR_DANCERS]
js> p3 = EvalPrim.apply(StandardDancer.COUPLE_3_BOY, f, prim2)
DancerPath[from=0,-1,w,[ROLL_RIGHT, SWEEP_LEFT],to=-1,0,n,[ROLL_RIGHT, SWEEP_LEFT],time=1 1/2,pointOfRotation=FOUR_DANCERS]
js> f = f.move(StandardDancer.COUPLE_1_BOY, p1.to).move(
  >            StandardDancer.COUPLE_3_BOY, p3.to); f.toStringDiagram()
  3G>

3B^  1Bv

  1G<
js> // boys extend, girls finish the trade. girls can roll and sweep.
js> p1 = EvalPrim.apply(StandardDancer.COUPLE_1_BOY, f, prim1)
DancerPath[from=1,0,s,[ROLL_RIGHT, SWEEP_LEFT],to=1,-1,s,[SWEEP_LEFT],time=1 1/2,pointOfRotation=<null>]
js> p2 = EvalPrim.apply(StandardDancer.COUPLE_1_GIRL, f, prim3)
DancerPath[from=0,-2,w,[ROLL_RIGHT, SWEEP_LEFT],to=-1,-1,n,[ROLL_RIGHT, SWEEP_LEFT],time=3,pointOfRotation=FOUR_DANCERS]
js> p3 = EvalPrim.apply(StandardDancer.COUPLE_3_BOY, f, prim1)
DancerPath[from=-1,0,n,[ROLL_RIGHT, SWEEP_LEFT],to=-1,1,n,[SWEEP_LEFT],time=1 1/2,pointOfRotation=<null>]
js> p4 = EvalPrim.apply(StandardDancer.COUPLE_3_GIRL, f, prim3)
DancerPath[from=0,2,e,[ROLL_RIGHT, SWEEP_LEFT],to=1,1,s,[ROLL_RIGHT, SWEEP_LEFT],time=3,pointOfRotation=FOUR_DANCERS]
js> f = f.move(StandardDancer.COUPLE_1_BOY, p1.to).move(
  >            StandardDancer.COUPLE_1_GIRL, p2.to).move(
  >            StandardDancer.COUPLE_3_BOY, p3.to).move(
  >            StandardDancer.COUPLE_3_GIRL, p4.to); f.toStringDiagram()
3B^  3Gv

1G^  1Bv
js> // roll!
js> f = f.move(StandardDancer.COUPLE_1_BOY, p1.to.turn(p1.to.roll(),false)).move(
  >            StandardDancer.COUPLE_1_GIRL, p2.to.turn(p2.to.roll(),false)).move(
  >            StandardDancer.COUPLE_3_BOY, p3.to.turn(p3.to.roll(),false)).move(
  >            StandardDancer.COUPLE_3_GIRL, p4.to.turn(p4.to.roll(),false)); f.toStringDiagram()
3B^  3G<

1G>  1Bv
Prims which "stand still" preserve roll by including the PRESERVE_ROLL flag.
js> importPackage(net.cscott.sdr.calls.ast)
js> fm = MatcherList.COUPLE.match(Formation.FOUR_SQUARE); undefined
js> f=[ff for (ff in Iterator(fm.matches.values()))
  >    if (ff.dancers().contains(StandardDancer.COUPLE_1_BOY))][0]; f.toStringDiagram()
1B^  1G^
js> // boy face out
js> p1a = EvalPrim.apply(StandardDancer.COUPLE_1_BOY, f,
  >                      AstNode.valueOf('(Prim 0, 0, out 1/4, 3)'))
DancerPath[from=-1,0,n,to=-1,0,w,[ROLL_LEFT],time=3,pointOfRotation=SINGLE_DANCER]
js> f = f.move(StandardDancer.COUPLE_1_BOY, p1a.to); f.toStringDiagram()
1B<  1G^
js> // do nothing (but preserve roll)
js> p1b = EvalPrim.apply(StandardDancer.COUPLE_1_BOY, f,
  >                      AstNode.valueOf('(Prim 0, 0, none, 3, preserve-roll)'))
DancerPath[from=-1,0,w,[ROLL_LEFT],to=-1,0,w,[ROLL_LEFT],time=3,pointOfRotation=<null>]
js> f = f.move(StandardDancer.COUPLE_1_BOY, p1b.to); f.toStringDiagram()
1B<  1G^
js> // do nothing (not preserving roll)
js> p1c = EvalPrim.apply(StandardDancer.COUPLE_1_BOY, f,
  >                      AstNode.valueOf('(Prim 0, 0, none, 3)'))
DancerPath[from=-1,0,w,[ROLL_LEFT],to=-1,0,w,time=3,pointOfRotation=<null>]
js> f = f.move(StandardDancer.COUPLE_1_BOY, p1c.to); f.toStringDiagram()
1B<  1G^
Tricky 45-degree off Prim. This is the outsides part of a fan the top, broken in halves.
js> importPackage(net.cscott.sdr.calls.ast)
js> FormationList = FormationList.js(this); undefined;
js> f = FormationList.SINGLE_DANCER; d = f.dancers().iterator().next();
<phantom@7b>
js> p = EvalPrim.apply(d, f, AstNode.valueOf('(Prim 0, 3, -1/8, 1 1/2)'))
DancerPath[from=0,0,n,to=0,3,nw,[ROLL_LEFT],time=1 1/2,pointOfRotation=SINGLE_DANCER]
js> f = f.move(d, p.to) ; undefined
js> p = EvalPrim.apply(d, f, AstNode.valueOf('(Prim -1 1/2, 1 1/2, -1/8, 1 1/2)'))
DancerPath[from=0,3,nw,[ROLL_LEFT],to=-3,3,w,[ROLL_LEFT, SWEEP_RIGHT],time=1 1/2,pointOfRotation=SINGLE_DANCER]

Constructor Summary
EvalPrim()
           
 
Method Summary
static DancerPath apply(Dancer d, Formation f, Prim p)
          "Dance" the given primitive for the given dancer in the given formation to yield a DancerPath for that dancer.
static DancerPath apply(Prim prim, Position from, int formationSize)
          "Dance" the given primitive from the given position (in a formation of the given size) to yield a DancerPath.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EvalPrim

public EvalPrim()
Method Detail

apply

public static DancerPath apply(Dancer d,
                               Formation f,
                               Prim p)
"Dance" the given primitive for the given dancer in the given formation to yield a DancerPath for that dancer.


apply

public static DancerPath apply(Prim prim,
                               Position from,
                               int formationSize)
"Dance" the given primitive from the given position (in a formation of the given size) to yield a DancerPath.


sdr 0.7

Copyright © 2006-2009 C. Scott Ananian