<commit_before>
interface Channel {
  PVector getPosition(float r);
  void draw();
  void snugTo(Gear moveable, Gear fixed); // position moveable gear on this channel so it is snug to fixed gear, not needed for all channels
}

class MountPoint implements Channel {
  Channel itsChannel = null;
  float itsMountRatio;
  float x, y;
  String typeStr = "MP";

  MountPoint(String typeStr, float x, float y) {
    this.typeStr = typeStr;
    this.itsChannel = null;
    this.itsMountRatio = 0;
    this.x = x*inchesToPoints;
    this.y = y*inchesToPoints;
    println(this.typeStr + " is at " + this.x/inchesToPoints + "," + this.y/inchesToPoints);
  }

  MountPoint(String typeStr, Channel ch, float mr) {
    this.typeStr = typeStr;
    this.itsChannel = ch;
    this.itsMountRatio = mr;
    PVector pt = ch.getPosition(mr);
    this.x = pt.x;
    this.y = pt.y;
    println(this.typeStr + " is at " + this.x/inchesToPoints + "," + this.y/inchesToPoints);
    if (ch instanceof Gear) {
      println("  " + this.typeStr + " is mounted on a gear");
    }
  }

  PVector getPosition() {
    return getPosition(0.0);
  }

  PVector getPosition(float r) {
    if (itsChannel != null) {
      return itsChannel.getPosition(itsMountRatio);
    } else {
      return new PVector(x,y);
    }
  }

  void snugTo(Gear moveable, Gear fixed) { // not meaningful
  }
  
  void draw() {
    PVector p = getPosition();
    if (itsChannel instanceof ConnectingRod) {
      itsChannel.draw();
    } 
    noFill();
    stroke(180);
    strokeWeight(1);
    ellipse(p.x, p.y, 12, 12);
  }
}

class ConnectingRod implements Channel {
  MountPoint itsSlide = null;
  MountPoint itsAnchor = null;
  float armAngle = 0;

  ConnectingRod(MountPoint itsSlide, MountPoint itsAnchor)
  {
    this.itsSlide = itsSlide;
    this.itsAnchor = itsAnchor;
  }
  
  PVector getPosition(float r) {
    PVector ap = itsAnchor.getPosition();
    PVector sp = itsSlide.getPosition();
    armAngle = atan2(sp.y - ap.y, sp.x - ap.x);
    
    return new PVector(ap.x + cos(armAngle)*r, ap.y + sin(armAngle)*r);
  }  

  void snugTo(Gear moveable, Gear fixed) {
    // !! find position on arc which causes moveable to be snug to fixed
  }
  
  void draw() {
    itsSlide.draw();
    itsAnchor.draw();
    noFill();
    stroke(100,200,100);
    strokeWeight(.23*inchesToPoints);
    PVector ap = itsAnchor.getPosition();
    PVector sp = itsSlide.getPosition();
    armAngle = atan2(sp.y - ap.y, sp.x - ap.x);
    // println("Drawing arm " + ap.x/inchesToPoints +" " + ap.y/inchesToPoints + " --> " + sp.x/inchesToPoints + " " + sp.y/inchesToPoints);
    float L = 18 * inchesToPoints;
    line(ap.x,ap.y, ap.x+cos(armAngle)*L, ap.y+sin(armAngle)*L);
  }
}

class PenRig {
  float itsMountLength;
  float len;
  float angle;
  ConnectingRod itsRod;

  PenRig(float len, float angle, ConnectingRod itsRod, float ml) {
    this.len = len * inchesToPoints;
    this.angle = angle;
    this.itsRod = itsRod;
    this.itsMountLength = ml * inchesToPoints;
    PVector ap = itsRod.getPosition(this.itsMountLength);
    PVector ep = this.getPosition();
    println("Pen Extender " + ap.x/inchesToPoints +" " + ap.y/inchesToPoints + " --> " + ep.x/inchesToPoints + " " + ep.y/inchesToPoints);
  }

  PVector getPosition() {
    PVector ap = itsRod.getPosition(this.itsMountLength);
    
    return new PVector(ap.x + cos(itsRod.armAngle + this.angle)*this.len, ap.y + sin(itsRod.armAngle + this.angle)*this.len);
  }
  
  void draw() {
    itsRod.draw();
    PVector ap = itsRod.getPosition(this.itsMountLength);
    PVector ep = this.getPosition();
    noFill();
    stroke(200,150,150);
    strokeWeight(.23*inchesToPoints);
    line(ap.x, ap.y, ep.x, ep.y);
  }
}

class LineRail implements Channel {
  float x1,y1, x2,y2;
  LineRail(float x1, float y1, float x2, float  y2) {
    this.x1 = x1*inchesToPoints;
    this.y1 = y1*inchesToPoints;
    this.x2 = x2*inchesToPoints;
    this.y2 = y2*inchesToPoints;
  }
  PVector getPosition(float r) {
    return new PVector(x1+(x2-x1)*r, y1+(y2-y1)*r);
  }  
<commit_msg>Cosmetics.<commit_after>
interface Channel {
  PVector getPosition(float r);
  void draw();
  void snugTo(Gear moveable, Gear fixed); // position moveable gear on this channel so it is snug to fixed gear, not needed for all channels
}

class MountPoint implements Channel {
  Channel itsChannel = null;
  float itsMountRatio;
  float x, y;
  String typeStr = "MP";

  MountPoint(String typeStr, float x, float y) {
    this.typeStr = typeStr;
    this.itsChannel = null;
    this.itsMountRatio = 0;
    this.x = x*inchesToPoints;
    this.y = y*inchesToPoints;
    println(this.typeStr + " is at " + this.x/inchesToPoints + "," + this.y/inchesToPoints);
  }

  MountPoint(String typeStr, Channel ch, float mr) {
    this.typeStr = typeStr;
    this.itsChannel = ch;
    this.itsMountRatio = mr;
    PVector pt = ch.getPosition(mr);
    this.x = pt.x;
    this.y = pt.y;
    println(this.typeStr + " is at " + this.x/inchesToPoints + "," + this.y/inchesToPoints);
    if (ch instanceof Gear) {
      println("  " + this.typeStr + " is mounted on a gear");
    }
  }

  PVector getPosition() {
    return getPosition(0.0);
  }

  PVector getPosition(float r) {
    if (itsChannel != null) {
      return itsChannel.getPosition(itsMountRatio);
    } else {
      return new PVector(x,y);
    }
  }

  void snugTo(Gear moveable, Gear fixed) { // not meaningful
  }
  
  void draw() {
    PVector p = getPosition();
    if (itsChannel instanceof ConnectingRod) {
      itsChannel.draw();
    } 
    noFill();
    stroke(180);
    strokeWeight(1);
    ellipse(p.x, p.y, 12, 12);
  }
}

class ConnectingRod implements Channel {
  MountPoint itsSlide = null;
  MountPoint itsAnchor = null;
  float armAngle = 0;

  ConnectingRod(MountPoint itsSlide, MountPoint itsAnchor)
  {
    this.itsSlide = itsSlide;
    this.itsAnchor = itsAnchor;
  }
  
  PVector getPosition(float r) {
    PVector ap = itsAnchor.getPosition();
    PVector sp = itsSlide.getPosition();
    armAngle = atan2(sp.y - ap.y, sp.x - ap.x);
    
    return new PVector(ap.x + cos(armAngle)*r, ap.y + sin(armAngle)*r);
  }  

  void snugTo(Gear moveable, Gear fixed) {
    // !! find position on arc which causes moveable to be snug to fixed
  }
  
  void draw() {
    PVector ap = itsAnchor.getPosition();
    PVector sp = itsSlide.getPosition();

    itsSlide.draw();
    itsAnchor.draw();
    pushMatrix();
      translate(sp.x, sp.y);
      noFill();
      stroke(100);
      fill(254,214,179,192);
      strokeWeight(2);
      ellipse(0,0,20,20);
    popMatrix();
    
    noFill();
    stroke(100,200,100);
    strokeWeight(.23*inchesToPoints);
    armAngle = atan2(sp.y - ap.y, sp.x - ap.x);
    // println("Drawing arm " + ap.x/inchesToPoints +" " + ap.y/inchesToPoints + " --> " + sp.x/inchesToPoints + " " + sp.y/inchesToPoints);
    float L = 18 * inchesToPoints;
    line(ap.x,ap.y, ap.x+cos(armAngle)*L, ap.y+sin(armAngle)*L);
  }
}

class PenRig {
  float itsMountLength;
  float len;
  float angle;
  ConnectingRod itsRod;

  PenRig(float len, float angle, ConnectingRod itsRod, float ml) {
    this.len = len * inchesToPoints;
    this.angle = angle;
    this.itsRod = itsRod;
    this.itsMountLength = ml * inchesToPoints;
    PVector ap = itsRod.getPosition(this.itsMountLength);
    PVector ep = this.getPosition();
    println("Pen Extender " + ap.x/inchesToPoints +" " + ap.y/inchesToPoints + " --> " + ep.x/inchesToPoints + " " + ep.y/inchesToPoints);
  }

  PVector getPosition() {
    PVector ap = itsRod.getPosition(this.itsMountLength);
    
    return new PVector(ap.x + cos(itsRod.armAngle + this.angle)*this.len, ap.y + sin(itsRod.armAngle + this.angle)*this.len);
  }
  
  void draw() {
    itsRod.draw();
    PVector ap = itsRod.getPosition(this.itsMountLength);
    PVector ep = this.getPosition();
    noFill();
    stroke(200,150,150);
    strokeWeight(.13*inchesToPoints);
    line(ap.x, ap.y, ep.x, ep.y);
  }
}

class LineRail implements Channel {
  float x1,y1, x2,y2;
  LineRail(float x1, float y1, float x2, float  y2) {
    this.x1 = x1*inchesToPoints;
    this.y1 = y1*inchesToPoints;
    this.x2 = x2*inchesToPoints;
    this.y2 = y2*inchesToPoints;
  }
  PVector getPosition(float r) {
    return new PVector(x1+(x2-x1)*r, y1+(y2-y1)*r);
  }  

{'fraction_non_alphanumeric': 0.13591532355063748, 'fraction_numerical': 0.017079624729372144, 'mean_word_length': 2.972766364070712, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7408963', 'n_tokens_mistral': 3157, 'n_tokens_neox': 3019, 'n_words': 669}