<commit_before>/********************************
 Body class
 
 this is the parent of all the body classes
 
 it defines the position and motion of a body
 centriod and the basic operations on a body.
 
 example code:
 Body body;
 void setup(){
 size(400,400);
 body = new Body(10,50,new Window(100,100));
 }
 void draw(){
 background(0);
 body.update();
 body.display();
 }
 void mousePressed(){body.mousePressed();}
 void mouseReleased(){body.mouseReleased();}
 ********************************/

class Body {
  Window window;
  final color bodyColor = #993333;
  float phi=0, dphi=0;
  int hx, hy;
  ArrayList<PVector> coords;
  int n;
  boolean unsteady, pressed;
  PVector xc, dxc;
  OrthoNormal orth[];
  Body box;

  Body( float x, float y, Window window ) {
    this.window = window;
    xc = new PVector(x, y);
    dxc = new PVector(0, 0);
    coords = new ArrayList();
  }
  
  void add( float x, float y ){
    coords.add( new PVector( x, y ) );
// remove concave points
    for ( int i = 0; i<coords.size() && coords.size()>3; i++ ){
      PVector x1 = coords.get(i);
      PVector x2 = coords.get((i+1)%coords.size());
      PVector x3 = coords.get((i+2)%coords.size());
      PVector t1 = PVector.sub(x1,x2);
      PVector t2 = PVector.sub(x2,x3);
      float a = atan2(t1.y,t1.x)-atan2(t2.y,t2.x);
      if(sin(a)<0){
       coords.remove((i+1)%coords.size());
       i=0;
      }
    }
  }
  
  void end(Boolean closed){
    n = coords.size();
    orth = new OrthoNormal[closed?n:n-1];
    getOrth(); // get orthogonal projection of line segments

    // make the bounding box
    if(n>4){
      PVector mn = xc.get();
      PVector mx = xc.get();
      for ( PVector x: coords ) {
        mn.x = min(mn.x,x.x);
        mn.y = min(mn.y,x.y);
        mx.x = max(mx.x,x.x);
        mx.y = max(mx.y,x.y);
      }
      box = new ConvexBody(xc.x,xc.y,window);
      box.add(mn.x,mn.y);
      box.add(mn.x,mx.y);
      box.add(mx.x,mx.y);
      box.add(mx.x,mn.y);
      box.end();
    }
  }
  void end(){end(true);}

  void getOrth(){    // get orthogonal projection to speed-up distance()
    for( int i = 0; i<orth.length ; i++ ) {
      PVector x1 = coords.get(i);
      PVector x2 = coords.get((i+1)%n);
      orth[i] = new OrthoNormal(x1,x2);<commit_msg>I had left a call to ConvexBody which does not exist any more.<commit_after>/********************************
 Body class
 
 this is the parent of all the body classes
 
 it defines the position and motion of a body
 centriod and the basic operations on a body.
 
 example code:
 Body body;
 void setup(){
 size(400,400);
 body = new Body(10,50,new Window(100,100));
 }
 void draw(){
 background(0);
 body.update();
 body.display();
 }
 void mousePressed(){body.mousePressed();}
 void mouseReleased(){body.mouseReleased();}
 ********************************/

class Body {
  Window window;
  final color bodyColor = #993333;
  float phi=0, dphi=0;
  int hx, hy;
  ArrayList<PVector> coords;
  int n;
  boolean unsteady, pressed;
  PVector xc, dxc;
  OrthoNormal orth[];
  Body box;

  Body( float x, float y, Window window ) {
    this.window = window;
    xc = new PVector(x, y);
    dxc = new PVector(0, 0);
    coords = new ArrayList();
  }
  
  void add( float x, float y ){
    coords.add( new PVector( x, y ) );
// remove concave points
    for ( int i = 0; i<coords.size() && coords.size()>3; i++ ){
      PVector x1 = coords.get(i);
      PVector x2 = coords.get((i+1)%coords.size());
      PVector x3 = coords.get((i+2)%coords.size());
      PVector t1 = PVector.sub(x1,x2);
      PVector t2 = PVector.sub(x2,x3);
      float a = atan2(t1.y,t1.x)-atan2(t2.y,t2.x);
      if(sin(a)<0){
       coords.remove((i+1)%coords.size());
       i=0;
      }
    }
  }
  
  void end(Boolean closed){
    n = coords.size();
    orth = new OrthoNormal[closed?n:n-1];
    getOrth(); // get orthogonal projection of line segments

    // make the bounding box
    if(n>4){
      PVector mn = xc.get();
      PVector mx = xc.get();
      for ( PVector x: coords ) {
        mn.x = min(mn.x,x.x);
        mn.y = min(mn.y,x.y);
        mx.x = max(mx.x,x.x);
        mx.y = max(mx.y,x.y);
      }
      box = new Body(xc.x,xc.y,window);
      box.add(mn.x,mn.y);
      box.add(mn.x,mx.y);
      box.add(mx.x,mx.y);
      box.add(mx.x,mn.y);
      box.end();
    }
  }
  void end(){end(true);}

  void getOrth(){    // get orthogonal projection to speed-up distance()
    for( int i = 0; i<orth.length ; i++ ) {
      PVector x1 = coords.get(i);
      PVector x2 = coords.get((i+1)%n);
      orth[i] = new OrthoNormal(x1,x2);
{'fraction_non_alphanumeric': 0.1895310796074155, 'fraction_numerical': 0.024863685932388222, 'mean_word_length': 2.5828125, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, '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': '6353455', 'n_tokens_mistral': 1811, 'n_tokens_neox': 1738, 'n_words': 431}