/**
   * Create a single {@link com.rackspacecloud.blueflood.service.SingleRollupWriteContext} from the
   * given {@link com.rackspacecloud.blueflood.types.IMetric} and Granularity.
   *
   * @param destGran
   * @param metric
   * @return
   * @throws IOException
   */
  protected SingleRollupWriteContext createSingleRollupWriteContext(
      Granularity destGran, IMetric metric) throws IOException {

    Locator locator = metric.getLocator();

    Points<SimpleNumber> points = new Points<SimpleNumber>();
    points.add(
        new Points.Point<SimpleNumber>(
            metric.getCollectionTime(), new SimpleNumber(metric.getMetricValue())));

    BasicRollup rollup = BasicRollup.buildRollupFromRawSamples(points);

    return new SingleRollupWriteContext(
        rollup,
        locator,
        destGran,
        CassandraModel.getBasicColumnFamily(destGran),
        metric.getCollectionTime());
  }
Пример #2
0
  public PlayerSpring(Wall w) {
    this.wall = w;
    points = new Points();
    points.add(lh = new XYPoint(-0.5, 2.0));
    points.add(le = new XYPoint(-0.3, 1.7));
    points.add(ls = new XYPoint(-0.2, 1.58));

    points.add(rh = new XYPoint(0.5, 2.0));
    points.add(re = new XYPoint(0.3, 1.7));
    points.add(rs = new XYPoint(0.2, 1.58));

    points.add(n = new XYPoint(0.0, 1.58));
    points.add(p = new XYPoint(0.0, 1.0));

    points.add(rn = new XYPoint(0.2, 0.7));
    points.add(rf = new XYPoint(0.2, 0.2));

    points.add(ln = new XYPoint(-0.2, 0.7));
    points.add(lf = new XYPoint(-0.2, 0.2));

    double k = 0.4;

    springs = new ArrayList<Spring>();

    springs.add(lClav = new Spring(0.2, k, n, ls, points));
    springs.add(lHum = new Spring(0.3, k, ls, le, points));
    springs.add(lRad = new Spring(0.33, k, le, lh, points));

    springs.add(rClav = new Spring(0.2, k, n, rs, points));
    springs.add(rHum = new Spring(0.3, k, rs, re, points));
    springs.add(rRad = new Spring(0.33, k, re, rh, points));

    springs.add(Lum1 = new Spring(0.58, k, n, p, points));
    springs.add(Lum2 = new Spring(0.58, k, p, n, points));

    springs.add(lFem = new Spring(0.44, k, p, ln, points));
    springs.add(lTib = new Spring(0.5, k, ln, lf, points));

    springs.add(rFem = new Spring(0.44, k, p, rn, points));
    springs.add(rTib = new Spring(0.5, k, rn, rf, points));

    joints = new ArrayList<Joint>();
    joints.add(new Joint(Lum2, lClav, Math.PI / 2.0, Math.PI / 2.0));
    joints.add(new Joint(Lum2, rClav, -Math.PI / 2.0, -Math.PI / 2.0));

    joints.add(new Joint(rClav, rHum, -Math.PI / 2.0, Math.PI / 2.0));
    joints.add(new Joint(rHum, rRad, 0.0, Math.PI / 2.0));

    joints.add(new Joint(lClav, lHum, -Math.PI / 2.0, Math.PI / 2.0));
    joints.add(new Joint(lHum, lRad, -Math.PI / 2.0, 0.0));

    joints.add(new Joint(Lum1, rFem, 0.1, 0.4));
    joints.add(new Joint(rFem, rTib, -0.2, 0.1));

    joints.add(new Joint(Lum1, lFem, -0.4, -0.1));
    joints.add(new Joint(lFem, lTib, -0.1, 0.2));

    points.translate(new XYPoint(5.0, 1.0));

    forces = new Points(points.size());
    velocity = new Points(points.size());
    velocity.zero();

    lhf = new XYPoint(0.0, 0.0);
    rhf = new XYPoint(0.0, 0.0);
    lff = new XYPoint(0.0, 0.0);
    rff = new XYPoint(0.0, 0.0);
    bf = new XYPoint(0.0, 0.0);

    leftaction = false;

    for (Spring s : springs) {
      XYPoint p1 = points.get(s.p1index);
      XYPoint p2 = points.get(s.p2index);
      XYPoint dif1 = s.p1distance().scale(0.6);
      XYPoint dif2 = s.p1distance().scale(-0.3);
      p2.translate(dif1);
      p1.translate(dif2);
    }

    for (Joint j : joints) {
      XYPoint v1 = j.s1.vector();
      XYPoint v2 = j.s2.vector();

      double angle = v1.angle(v2);

      if (angle < j.mina) {
        XYPoint v2r = v2.rotate(-(angle - j.mina));
        points.get(j.s2.p2index).set(points.get(j.s2.p1index).add(v2r));
      } else if (angle > j.maxa) {
        XYPoint v2r = v2.rotate((j.maxa - angle));
        points.get(j.s2.p2index).set(points.get(j.s2.p1index).add(v2r));
      }
    }
  }