Package toxi.geom

Examples of toxi.geom.Vec2D


    for (int i = 0; i < getCentrePath().size(); i++) {
      SketchPoint curVec = (SketchPoint) getCentrePath().get(i);

      if (this.outlineOffset.containsKey(i) && this.path.size() >= i) {
        if (this.path.size() > i) {
          Vec2D outline = (Vec2D) this.path.get(i);
          Vec2D offset = this.outlineOffset.get(i);
          outline.x = curVec.sub(offset).x;
          outline.y = curVec.sub(offset).y;
        }
        // this.outineLeft.set(i, outline);
      }

    }

    for (int i = 0; i < getCentrePath().size(); i++) {
      Vec2D curVec = (Vec2D) getCentrePath().get(i);
      int i2 = ((getCentrePath().size() * 2) - i - 1);
      if (this.outlineOffset.containsKey(i2) && this.path.size() >= i2) {
        if (this.path.size() >= i2) {
          Vec2D outline = (Vec2D) this.path.get(i2);
          Vec2D offset = this.outlineOffset.get(i2);
          outline.x = curVec.sub(offset).x;
          outline.y = curVec.sub(offset).y;
        }
        // this.outineLeft.set(i, outline);
      }
View Full Code Here


    if (this.getCentrePath() != null)
      newSpline.setCentrePath(this.getCentrePath().clone());

    for (int i = 0; i < this.outineLeft.size(); i++) {
      Vec2D curVec = this.outineLeft.get(i);
      newSpline.outineLeft.add(new SketchPoint(curVec.x, curVec.y));
    }

    for (int i = 0; i < this.outineRight.size(); i++) {
      Vec2D curVec = this.outineRight.get(i);
      newSpline.outineRight.add(new SketchPoint(curVec.x, curVec.y));
    }

    for (int i = 0; i < this.getCentrePath().size(); i++) {
      if (this.getCentreOffset().get(i) != null)
View Full Code Here

  public Vec2D getCentreOfMass() {
    long x = 0;
    long y = 0;

    for (int i = 0; i < this.getCombinedSize(); i++) {
      Vec2D v = (Vec2D) this.getCombined(i);
      x += v.x;
      y += v.y;
    }
    return new Vec2D(x / this.getCombinedSize(), y / this.getCombinedSize());
  }
View Full Code Here

  public SketchPoint getClosestPoint(Vec2D pointOnPlan) {
    return this.getCentrePath().getClosestPoint(pointOnPlan);
  }

  public Vec2D getClosestPointAlongPath(float x, float y) {
    Vec2D mPos = new Vec2D(x, y);
    Vec2D centreP = this.getCentrePath().getClosestPointAlongPath(x, y);
    Vec2D outlineP = this.getPath().getClosestPointAlongPath(x, y);

    if (mPos == null || centreP == null || outlineP == null)
      return null;

    if (centreP.distanceTo(mPos) < outlineP.distanceTo(mPos))
      return centreP;
    else
      return outlineP;

  }
View Full Code Here

    float length = 0;

    if (first == second)
      return length;

    Vec2D startVec = null;

    for (int i = 0; i < getCentrePath().size() - 1; i++) {
      Vec2D curVec = (Vec2D) getCentrePath().get(i);
      Vec2D nextVec = (Vec2D) getCentrePath().get(i + 1);

      if (startVec == null && (curVec == first || curVec == second))
        startVec = curVec;

      if (startVec != null)
View Full Code Here

      return null;
  }

  private int getIndex(Vec2D startVec) {
    for (int i = 0; i < getCentrePath().size(); i++) {
      Vec2D vec = (Vec2D) getCentrePath().get(i);
      if (startVec == vec)
        return i;
    }

    return -1;
View Full Code Here

  public float getlength() {
    float length = 0;

    for (int i = 0; i < getCentrePath().size() - 1; i++) {
      Vec2D curVec = (Vec2D) getCentrePath().get(i);
      Vec2D nextVec = (Vec2D) getCentrePath().get(i + 1);

      if (curVec != null && nextVec != null)
        length += curVec.distanceTo(nextVec);
    }
View Full Code Here

    if (curVecC == null)
      return -1;

    for (int i = 0; i < getCentrePath().size() - 1; i++) {
      Vec2D curVec = (Vec2D) getCentrePath().get(i);
      Vec2D nextVec = (Vec2D) getCentrePath().get(i + 1);

      if (curVecC != nextVec && curVecC != curVec && nextVec != null)
        length += curVec.distanceTo(nextVec);
      else
        return length;
View Full Code Here

    return -1;

  }

  private Vec2D getNearestVec(Vec2D selectedNode) {
    Vec2D foundVec = null;
    float dist = 0;

    for (int i = 0; i < getCentrePath().size(); i++) {
      Vec2D vec = (Vec2D) getCentrePath().get(i);
      if (vec.distanceTo(selectedNode) < dist || foundVec == null) {
        dist = vec.distanceTo(selectedNode);
        foundVec = vec;
      }
    }

    return foundVec;
View Full Code Here

  private int getNearestVecIndex(Vec2D selectedNode) {
    int index = -1;
    float dist = 0;

    for (int i = 0; i < getCentrePath().size(); i++) {
      Vec2D vec = (Vec2D) getCentrePath().get(i);
      if (vec.distanceTo(selectedNode) < dist || index == -1) {
        dist = vec.distanceTo(selectedNode);
        index = i;
      }
    }

    return index;
View Full Code Here

TOP

Related Classes of toxi.geom.Vec2D

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.