Package cranks.geom

Examples of cranks.geom.Angle


    links[1].connectTo(links[0]);
    links[2].connectTo(links[1]);
    links[3].connectTo(links[2]);
    links[0].connectTo(links[3]);
    fixed = 0;
    inputAngle = new Angle();
    increment = new Angle(Math.PI/180); //Dummy value
    animationDelay = 0;
    ternaryTrace = new Vector<Point>();
    initialize();
    elbowUp = true;
    drawTrace = false;
View Full Code Here


  private void updateChainProperties() {
    if (isMechanism()) {
      setExtremes();
      setGrashof();
      setJointRanges();
      inputAngle.setAngle(rotationRange.getStart().add(new Angle(Math.PI/180)));
      double l1 = getLink(1).getLength();
      double l2 = getLink(2).getLength();
      double l3 = getLink(3).getLength();
      double l4 = getLink(4).getLength();
      getLink(1).getPostJoint().setCoordinates(-(l1/2), 0);
View Full Code Here

  private Angle start;
  private Angle end;

  public Range() {
    start = new Angle();
    end = new Angle();
  }
View Full Code Here

  public Link(double Length) {
    number = -1;
    length = Length;
    ternary = false;
    ternaryLength = 0;
    ternaryAngle = new Angle();
  }
View Full Code Here

    return ternaryAngle;
  }

  public Point getCouplerPoint() {
    if (ternary) {
      Angle slopeOfLink = (new Line(preJoint, postJoint)).getSlope();
      return (new Line(getPreviousJoint(), slopeOfLink.add(ternaryAngle),
                        ternaryLength)).getEnd();
    }
    else
      return null;
  }
View Full Code Here

      Object obj1 = step.getInputs()[1];
      Object obj2 = step.getInputs()[2];
      boolean lengthReference = (obj1 instanceof GeometricalObject);
      boolean slopeReference = (obj2 instanceof GeometricalObject);
      double length;
      Angle slope;
      if (lengthReference) {
        if (step.getInputs()[1] instanceof Line)
          length = ((Line)obj1).getLength();
        else
          length = ((Circle)obj1).getRadius();
      }
      else {
        length = ((Double)obj1).doubleValue();
        if (!(Math.abs(length) > 0)) {
          JOptionPane.showMessageDialog(this, "Please enter non-zero value for Length",
                    "Try Again", JOptionPane.ERROR_MESSAGE);
          initDialog();
        }
      }
      if (slopeReference)
        slope = new Angle(((Line)obj2).getSlope().getAngle());
      else {
        double slopeDegrees = ((Double)obj2).doubleValue();
        slope = new Angle(Math.toRadians(slopeDegrees));
      }
      Line newLine = new Line(p, slope, length);
      newLine.addToObjects(objects);
      if (lengthReference)
        if (obj1 instanceof Line) {
View Full Code Here

  public void redoConstruction(ConstructionStep step) {
    if (step.getConstructionType() == MOVE) {
      GeometricalObject o = (GeometricalObject)step.getInputs()[0];
      Point translation = new Point(((Double)step.getInputs()[1]).doubleValue(),
                                    ((Double)step.getInputs()[2]).doubleValue());
      Angle rotation = new Angle(((Double)step.getInputs()[3]).doubleValue());
      Point fixedPoint = (Point)step.getInputs()[4];
      o.move(translation, rotation, fixedPoint);
    }
    else
      System.err.println("Bad construction type");
View Full Code Here

      linkLengths[0] = Double.parseDouble(tfLink1.getText());
      linkLengths[1] = Double.parseDouble(tfLink2.getText());
      linkLengths[2] = Double.parseDouble(tfLink3.getText());
      linkLengths[3] = Double.parseDouble(tfLink4.getText());
      double ternaryLength = 0;
      Angle ternaryAngle = new Angle();
      if (rbTernary.isSelected()) {
        ternaryLength = Double.parseDouble(tfTernaryLength.getText());
        if (ternaryLength <= 0) {
          JOptionPane.showMessageDialog(this, "Please enter positive value " +
                "for length", "Try Again", JOptionPane.ERROR_MESSAGE);
          return;
        }
        ternaryAngle = new Angle(Math.toRadians(Double.parseDouble(
                                     tfTernaryAngle.getText())));
      }
      for (int i = 0; i<4; i++)
        if (linkLengths[i] <= 0) {
          JOptionPane.showMessageDialog(this, "Please enter positive value " +
View Full Code Here

                  (new Line(selectedSide.getStart(), newSide.getEnd()));
        Line line2 = (orientation)?
                  (new Line(selectedSide.getEnd(), newSide.getEnd())):
                  (new Line(selectedSide.getEnd(), newSide.getStart()));
        Point centreOfRotation;
        Angle angleOfRotation;
        if (line1.getLength() < Point.LEAST_COUNT) {
          centreOfRotation = new Point(line1.getStart().getX(),line1.getStart().getY());
          angleOfRotation = (new Line(centreOfRotation, line2.getEnd())).getSlope().
                    sub((new Line(centreOfRotation, line2.getStart())).getSlope());
        }
        else if (line2.getLength() < Point.LEAST_COUNT) {
          centreOfRotation = new Point(line2.getStart().getX(),line2.getStart().getY());
          angleOfRotation = (new Line(centreOfRotation, line1.getEnd())).getSlope().
                    sub((new Line(centreOfRotation, line1.getStart())).getSlope());
        }
        else {
          Line perpLine1 = new Line(line1.midPoint(),line1.getSlope().
                              add(new Angle(Math.PI/2)),1);
          Line perpLine2 = new Line(line2.midPoint(),line2.getSlope().
                              add(new Angle(Math.PI/2)),1);
          if (perpLine1.canIntersect(perpLine2)) {
            centreOfRotation = perpLine1.intersect(perpLine2)[0];
            angleOfRotation = (new Line(centreOfRotation, line1.getEnd())).getSlope().
                    sub((new Line(centreOfRotation, line1.getStart())).getSlope());
          }
          else {
            Point translation = new Point(
                      line1.getEnd().getX() - line1.getStart().getX(),
                      line1.getEnd().getY() - line1.getStart().getY());
            ptOppSelSide.move(translation, new Angle(0), new Point());
            Triangle newTriangle = new Triangle(ptOppSelSide, newSide);
            newTriangle.addToObjects(objects);
            clearAndHide();
            step.setOutputs(new Object[]{ptOppSelSide, newTriangle.getSides()[1],
                        newTriangle.getSides()[2], newTriangle});
View Full Code Here

      }
    }
    String fixedLink = (String)cFixedLink.getSelectedItem();
    int fixed = Integer.parseInt(fixedLink.substring(fixedLink.length()-1));
    double ternaryLength = 0;
    Angle ternaryAngle = new Angle();
    if (rbTernary.isSelected()) {
      Triangle ternaryLink = (Triangle)cTernaryLink.getSelectedItem();
      Line link3 = (fixed > 2)?(lines[(fixed-1)-2]):(lines[(fixed-1)+2]);
      if (!(link3.getAssocObjects().contains(ternaryLink))) {
        JOptionPane.showMessageDialog(this, "Ternary link is not connected to "+
View Full Code Here

TOP

Related Classes of cranks.geom.Angle

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.