Exemplo n.º 1
0
  //  public static ArrayList<UHeading> getHeadings(UVertexList input,float headingDamper) {
  //    ArrayList<UHeading> h=new ArrayList<UHeading>();
  //    UVertexList delta=input.deltaVectors(headingDamper);
  //    if(rndBool()) delta=deltaVectors2(input);
  //    for(UVertex hv:delta) h.add(new UHeading(hv));
  //    return h;
  //  }
  //
  protected static UVertexList deltaVectors2(UVertexList input) {
    UVertexList dl = new UVertexList();
    for (int i = 0; i < input.size(); i++) {
      UVertex tmp = null;
      if (i < input.size() - 1) {
        tmp = input.get(i + 1).copy().sub(input.get(i));
        if (i > 0) tmp.add(input.get(i).copy().sub(input.get(i - 1))).mult(0.5f);
      } else tmp = input.get(i).copy().sub(input.get(i - 1));
      dl.add(tmp);
    }

    return dl;
  }
Exemplo n.º 2
0
  protected static UVertexList deltaVectors3(UVertexList input) {
    UVertexList dl = new UVertexList();

    boolean isClosed = input.isClosed();

    for (int i = 0; i < input.size(); i++) {
      UVertex vv = null, vn = null, vp = null;
      vv = input.get(i);

      if (i > 0) vp = input.get(i - 1);
      if (i == 0 && isClosed) vp = input.last();

      if (i < input.size() - 1) vn = input.get(i + 1);
      else if (isClosed) vn = input.first();

      if (vn != null) vn = vn.copy().sub(vv); // .norm();
      if (vp != null) vp = vv.copy().sub(vp); // .norm();

      if (vp != null && vn != null) vv = vn.add(vp).mult(0.5f);
      else if (vn == null) vv = vp;
      else vv = vn;

      log(
          i
              + "/"
              + input.size()
              + " "
              + isClosed
              + " vp="
              + (vp != null)
              + " vn="
              + (vn != null)
              + " "
              + vv.str());

      dl.add(vv);

      //      if(i<input.size()-1) {
      //        tmp=input.get(i+1).copy().sub(input.get(i)).norm();
      //        if(i>0) tmp.add(
      //            input.get(i).copy().sub(input.get(i-1)).norm()).mult(0.5f);
      //      }
      //      else tmp=input.get(i).copy().sub(input.get(i-1));
      //      dl.add(tmp);
    }

    return dl;
  }