Package toxi.geom

Examples of toxi.geom.Vec2D


        curVec.isOver = false;
      }
    }

    for (int i = 0; i < size(); i++) {
      Vec2D curVec = (Vec2D) get(i);

      g.vertex(curVec.x, curVec.y);

      //
      // selectDia);
View Full Code Here


      }

      if (curVec.containsBezier() || preVec != null
          && preVec.containsBezier()) {

        Vec2D c1 = preVec;
        Vec2D c2 = curVec;

        if (c1 == null)
          c1 = new SketchPoint(0, 0);

        if (preVec != null && preVec.containsBezier()) {
View Full Code Here

  public void rotate(float r, Vec2D centre) {

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

      Vec2D v = functions.rotate(curVec, centre, r);
      curVec.x = v.x;
      curVec.y = v.y;

      if (curVec.containsBezier()) {
View Full Code Here

      SketchPoint v = this.l.get(i);

      SketchPoint point = new SketchPoint(v.x, v.y);

      if (v.controlPoint1 != null) {
        point.controlPoint1 = new Vec2D(v.controlPoint1.x,
            v.controlPoint1.y);
      }

      if (v.controlPoint2 != null) {
        point.controlPoint2 = new Vec2D(v.controlPoint2.x,
            v.controlPoint2.y);
      }

      loop.add(point);
View Full Code Here

    for (int i = 0; i < this.l.size(); i++) {
      SketchPoint v = this.l.get(i);
      SketchPoint point = new SketchPoint(v.x, v.y);

      if (v.controlPoint1 != null) {
        point.controlPoint1 = new Vec2D(v.controlPoint1.x,
            v.controlPoint1.y);
      }

      if (v.controlPoint2 != null) {
        point.controlPoint2 = new Vec2D(v.controlPoint2.x,
            v.controlPoint2.y);
      }

      loop.add(point);
View Full Code Here

      for (int i = 0; i < size(); i++) {
        if (i == 0) // is first
        {
          SketchPoint p1 = get(i);
          SketchPoint p2 = get(i + 1);
          Vec2D tangent = p2.sub(p1);
          Vec2D q1 = p1.add(tangent.scale(scale));
          p1.controlPoint1 = p1;
          p1.controlPoint2 = q1;
        } else if (i == size() - 1) //last
        {
          SketchPoint p0 = get(i - 1);
          SketchPoint p1 = get(i);
          Vec2D tangent = p1.sub(p0);
          Vec2D q0 = p1.sub(tangent.scale(scale));

          p1.controlPoint1 = q0;
          p1.controlPoint2 = p1.copy();
        } else {

          SketchPoint p0, p1, p2;
          p0 = get(i - 1);
          p1 = get(i);
          p2 = get(i + 1);

          Vec2D tangent = (p2.sub(p0)).normalize();
          Vec2D q0 = p1.sub(tangent.scale(scale).scale(
              p1.sub(p0).magnitude()));
          Vec2D q1 = p1.add(tangent.scale(scale).scale(
              p2.sub(p1).magnitude()));
          p1.controlPoint2 = q0;
          p1.controlPoint1 = q1;

        }
      }
    } else {
      for (int i = 0; i < size(); i++) {

        SketchPoint p0, p1, p2;
        if (i > 0)
          p0 = get(i - 1);
        else
          p0 = get(size() - 1);

        p1 = get(i);

        if (i < size() - 1)
          p2 = get(i + 1);
        else
          p2 = get(0);

        Vec2D tangent = (p2.sub(p0)).normalize();
        Vec2D q0 = p1.sub(tangent.scale(scale).scale(
            p1.sub(p0).magnitude()));
        Vec2D q1 = p1.add(tangent.scale(scale).scale(
            p2.sub(p1).magnitude()));
        p1.controlPoint1 = q0;
        p1.controlPoint2 = q1;

      }
View Full Code Here

  public void applyRotationMatrix(PGraphics g) {

    g.translate(this.getPlane().x, this.getPlane().y, this.getPlane().z);

    // g.rotateX(this.plane.normal.headingXY());
    g.rotateY((float) (functions.angleOf(new Vec2D(
        this.getPlane().normal.x, this.getPlane().normal.z)) - (Math.PI / 2)));
    // g.rotateY((float) Math.PI/2);

    float rotateAn = (functions.angleOf(new Vec2D(this.getPlane().normal.x,
        this.getPlane().normal.y)));

    // rotateAn = this.testAn;

    if (rotateAn < Math.PI / 2 || rotateAn > (Math.PI / 2) * 3)
 
View Full Code Here

      for (int i = size() - 1; i >= 0; i--) {
        if (i == 0) // is first
        {
          SketchPoint p1 = get(i);
          SketchPoint p2 = get(i + 1);
          Vec2D tangent = p2.sub(p1);
          Vec2D q1 = p1.add(tangent.scale(scale));
          p1.controlPoint1 = p1;
          p1.controlPoint2 = q1;
        } else if (i == size() - 1) //last
        {
          SketchPoint p0 = get(i - 1);
          SketchPoint p1 = get(i);
          Vec2D tangent = p1.sub(p0);
          Vec2D q0 = p1.sub(tangent.scale(scale));

          p1.controlPoint1 = q0;
          p1.controlPoint2 = p1.copy();
        } else {

          SketchPoint p0, p1, p2;
          p0 = get(i + 1);
          p1 = get(i);
          p2 = get(i - 1);

          Vec2D tangent = (p2.sub(p0)).normalize();
          Vec2D q0 = p1.sub(tangent.scale(scale).scale(
              p1.sub(p0).magnitude()));
          Vec2D q1 = p1.add(tangent.scale(scale).scale(
              p2.sub(p1).magnitude()));
          p1.controlPoint2 = q0;
          p1.controlPoint1 = q1;

        }
      }
    } else {
      for (int i = size() - 1; i >= 0; i--) {

        SketchPoint p0, p1, p2;
        if (i > 0)
          p0 = get(i - 1);
        else
          p0 = get(size() - 1);

        p1 = get(i);

        if (i < size() - 1)
          p2 = get(i + 1);
        else
          p2 = get(0);

        Vec2D tangent = (p2.sub(p0)).normalize();
        Vec2D q0 = p1.sub(tangent.scale(scale).scale(
            p1.sub(p0).magnitude()));
        Vec2D q1 = p1.add(tangent.scale(scale).scale(
            p2.sub(p1).magnitude()));
        p1.controlPoint1 = q0;
        p1.controlPoint2 = q1;

      }
View Full Code Here

  public float getArea() {
    return this.getSketch().getArea();
  }

  public Vec3D getCentreOfMass() {
    Vec2D centre = this.getSketch().getCentreOfMass();

    if (centre != null)
      return new Vec3D(GLOBAL.jBullet.scaleVal(centre.x),
          GLOBAL.jBullet.scaleVal(centre.y),
          GLOBAL.jBullet.scaleVal(this.getPlane().z));
View Full Code Here

      }

      if (curVec.containsBezier() || preVec != null
          && preVec.containsBezier()) {

        Vec2D c1 = (SketchPoint) preVec;
        Vec2D c2 = (SketchPoint) curVec;

        if (c1 == null)
          c1 = new SketchPoint(0, 0);

        if (preVec != null && preVec.containsBezier()) {
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.