Package cranks.geom

Examples of cranks.geom.Circle


      double l4 = getLink(4).getLength();
      getLink(1).getPostJoint().setCoordinates(-(l1/2), 0);
      getLink(2).getPostJoint().setCoordinates(l2*Math.cos(inputAngle.getAngle())-(l1/2),
                                         l2*Math.sin(inputAngle.getAngle()));
      getLink(4).getPostJoint().setCoordinates(l1/2, 0);
      Circle circle1 = new Circle(getLink(2).getPostJoint(), l3);
      Circle circle2 = new Circle(getLink(4).getPostJoint(), l4);
      Point newJoint = (elbowUp)?(circle1.intersect(circle2)[0]):
                                 (circle1.intersect(circle2)[1]);
      if (newJoint != null)
        getLink(3).getPostJoint().setCoordinates(newJoint.getX(), newJoint.getY());
    }
View Full Code Here


    double l2 = getLink(2).getLength();
    double l3 = getLink(3).getLength();
    double l4 = getLink(4).getLength();
    getLink(2).getPostJoint().setCoordinates(l2*Math.cos(inputAngle.getAngle())-(l1/2),
                                       l2*Math.sin(inputAngle.getAngle()));
    Circle circle1 = new Circle(getLink(2).getPostJoint(), l3);
    Circle circle2 = new Circle(getLink(4).getPostJoint(), l4);
    Point[] points = circle1.intersect(circle2);
    if ((points[0] != null) && (points[1] != null)) {
      Point oldJoint = getLink(3).getPostJoint();
      Point newJoint = (points[0].distanceTo(oldJoint) <
                        points[1].distanceTo(oldJoint)) ?
View Full Code Here

          JOptionPane.showMessageDialog(this, "Please enter positive value for " +
                              "radius", "Try Again", JOptionPane.ERROR_MESSAGE);
          initDialog();
        }
      }
      Circle newCircle = new Circle(centre, radius);
      newCircle.addToObjects(objects);
      if (radiusReference)
        if (obj1 instanceof Line) {
          ((Line)obj1).addPropertyChangeListener(Line.PROP_LENGTH, newCircle);
          newCircle.addPropertyChangeListener(Circle.PROP_RADIUS, (Line)obj1);
        }
        else {
          ((Circle)obj1).addPropertyChangeListener(Circle.PROP_RADIUS, newCircle);
          newCircle.addPropertyChangeListener(Circle.PROP_RADIUS, (Circle)obj1);
        }
      clearAndHide();
      step.setOutputs(new Object[]{newCircle});
      fireUndoableEditUpdate(new UndoableEditEvent(this, step));
    }
    else if (step.getConstructionType() == THREE_POINTS) {
      Point point1 = (Point)step.getInputs()[0];
      Point point2 = (Point)step.getInputs()[1];
      Point point3 = (Point)step.getInputs()[2];
      Line line12 = new Line(point1, point2);
      Line line23 = new Line(point2, point3);
      if (!((line12.isParallel(line23))||(point1.equalTo(point2))
          || (point2.equalTo(point3)) || (point3.equalTo(point1))))  {
        Circle newCircle = new Circle(point1, point2, point3);
        newCircle.addToObjects(objects);
        clearAndHide();
        step.setOutputs(new Object[]{newCircle.getCentre(), newCircle});
        fireUndoableEditUpdate(new UndoableEditEvent(this, step));
      }
      else {
        JOptionPane.showMessageDialog(this, "Select three distinct"
             + " non-collinear points", "Try Again", JOptionPane.ERROR_MESSAGE);
View Full Code Here

        ((GeometricalObject)step.getOutputs()[i]).removeFromObjects(objects);
      for (int i = 0; i<objects.size(); i++)
        objects.elementAt(i).setNumber(i+1);
      if (step.getConstructionType() == CENTRE_RADIUS) {
        Object obj1 = step.getInputs()[1];
        Circle newCircle = (Circle)step.getOutputs()[0];
        if (!(obj1 instanceof Double))
          if (obj1 instanceof Line) {
            ((Line)obj1).removePropertyChangeListener(Line.PROP_LENGTH, newCircle);
            newCircle.removePropertyChangeListener(Circle.PROP_RADIUS, (Line)obj1);
          }
          else {
           ((Circle)obj1).removePropertyChangeListener(Circle.PROP_RADIUS, newCircle);
            newCircle.removePropertyChangeListener(Circle.PROP_RADIUS, (Circle)obj1);
         }
      }
    }
    else {
      System.err.println("Bad construction type");
View Full Code Here

        (step.getConstructionType() == THREE_POINTS)) {
      for(int i = 0; i < step.getOutputs().length; i++)
        ((GeometricalObject)step.getOutputs()[i]).addToObjects(objects);
      if (step.getConstructionType() == CENTRE_RADIUS) {
        Object obj1 = step.getInputs()[1];
        Circle newCircle = (Circle)step.getOutputs()[0];
        if (!(obj1 instanceof Double))
          if (obj1 instanceof Line) {
            ((Line)obj1).addPropertyChangeListener(Line.PROP_LENGTH, newCircle);
            newCircle.addPropertyChangeListener(Circle.PROP_RADIUS, (Line)obj1);
          }
          else {
           ((Circle)obj1).addPropertyChangeListener(Circle.PROP_RADIUS, newCircle);
            newCircle.addPropertyChangeListener(Circle.PROP_RADIUS, (Circle)obj1);
         }
      }
    }
    else {
      System.err.println("Bad construction type");
View Full Code Here

                new FieldInfo(Integer.toString(ob.getNumber()), ob));
              field.add(subField);
            }
          break;
          case 4:
            Circle c = ((Circle)o);
            field = new DefaultMutableTreeNode(
                      new FieldInfo("Centre Point", c.getCentre()));
            object.add(field);
            field = new DefaultMutableTreeNode(
                      new FieldInfo("Radius", c.getRadius()));
            object.add(field);
            field = new DefaultMutableTreeNode(
                      new FieldInfo("Visibility", c.isVisible()));
            object.add(field);
          break;
          case 5:
            Triangle t = ((Triangle)o);
            field = new DefaultMutableTreeNode(
View Full Code Here

    int lineNumber3 = (fixed > 2) ? (fixed - 3) : (fixed + 1);
    int lineNumber4 = (fixed == 1) ? 3 : (fixed - 2);
    Point joint23 = lines[lineNumber2].intersect(lines[lineNumber3])[0];
    Point joint34 = lines[lineNumber3].intersect(lines[lineNumber4])[0];
    Point joint41 = lines[lineNumber4].intersect(lines[lineNumber1])[0];
    Circle circleLink3 = new Circle(joint23, lines[lineNumber3].getLength());
    Circle circleLink4 = new Circle(joint41, lines[lineNumber4].getLength());
    mechanism.setElbow(joint34.equalTo(circleLink3.intersect(circleLink4)[0]));
  }
View Full Code Here

TOP

Related Classes of cranks.geom.Circle

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.