Esempio n. 1
0
 public Vector3 getSize(ReferenceFrame asSeenBy, HowMuch howMuch, boolean ignoreHidden) {
   Box box = getBoundingBox(asSeenBy, howMuch, ignoreHidden);
   if (box != null) {
     return new Vector3(box.getWidth(), box.getHeight(), box.getDepth());
   } else {
     return new Vector3(0, 0, 0);
   }
 }
Esempio n. 2
0
 public double getSizeAlongDimension(
     Dimension dimension, ReferenceFrame asSeenBy, HowMuch howMuch, boolean ignoreHidden) {
   Box box = getBoundingBox(asSeenBy, howMuch, ignoreHidden);
   if (box != null) {
     if (dimension == Dimension.LEFT_TO_RIGHT) {
       return box.getWidth();
     } else if (dimension == Dimension.TOP_TO_BOTTOM) {
       return box.getHeight();
     } else if (dimension == Dimension.FRONT_TO_BACK) {
       return box.getDepth();
     } else {
       throw new IllegalArgumentException(
           dimension + " is expected to be in [LEFT_TO_RIGHT, TOP_TO_BOTTOM, FRONT_TO_BACK].");
     }
   } else {
     // todo: Double.NaN?
     return 0;
   }
 }
Esempio n. 3
0
    protected javax.vecmath.Vector3d getPositionEnd() {
      if (m_subjectBoundingBox == null) {
        m_subjectBoundingBox = subject.getBoundingBox();

        if (m_subjectBoundingBox.getMaximum() == null) {
          m_subjectBoundingBox =
              new edu.cmu.cs.stage3.math.Box(
                  subject.getPosition(subject), subject.getPosition(subject));
        }
      }
      if (m_asSeenByBoundingBox == null) {
        m_asSeenByBoundingBox = m_asSeenBy.getBoundingBox();

        if (m_asSeenByBoundingBox.getMaximum() == null) {
          m_asSeenByBoundingBox =
              new edu.cmu.cs.stage3.math.Box(
                  m_asSeenBy.getPosition(m_asSeenBy), m_asSeenBy.getPosition(m_asSeenBy));
        }
      }
      edu.cmu.cs.stage3.alice.core.SpatialRelation sv = spatialRelation.getSpatialRelationValue();
      javax.vecmath.Vector3d v =
          sv.getPlaceVector(amount.doubleValue(), m_subjectBoundingBox, m_asSeenByBoundingBox);
      return v;
    }
Esempio n. 4
0
    public void setFinalOrientations() {
      // blah blah blah.
      rightUpperFinalOrient = new edu.cmu.cs.stage3.math.Matrix33();
      rightLowerFinalOrient = new edu.cmu.cs.stage3.math.Matrix33();
      rightLowerFinalOrient.rotateX(0.5 * java.lang.Math.PI);
      rightFootFinalOrient = new edu.cmu.cs.stage3.math.Matrix33();
      rightFootFinalOrient.rotateX(0.5 * java.lang.Math.PI);

      if (KneelAnimation.this.oneKnee.booleanValue()) {
        double lengthSupportLeg = 0.0;

        if ((rightLower == null)) {
          leftUpperFinalOrient = new edu.cmu.cs.stage3.math.Matrix33();
          leftUpperFinalOrient.rotateX(0.25 * java.lang.Math.PI);
          leftFootFinalOrient = new edu.cmu.cs.stage3.math.Matrix33();
          leftFootFinalOrient.rotateX(-0.25 * java.lang.Math.PI);

          rightUpperFinalOrient = new edu.cmu.cs.stage3.math.Matrix33();
          rightUpperFinalOrient.rotateX(-0.25 * java.lang.Math.PI);
          rightFootFinalOrient = new edu.cmu.cs.stage3.math.Matrix33();
          rightFootFinalOrient.rotateX(0.25 * java.lang.Math.PI);
        }

        if ((rightUpper != null) && (rightLower != null)) {
          Vector3 posLower = rightLower.getPosition(rightUpper);
          edu.cmu.cs.stage3.math.Box boxLower = rightLower.getBoundingBox(rightLower);

          lengthSupportLeg =
              java.lang.Math.abs(posLower.y) + java.lang.Math.abs(boxLower.getMinimum().z);

          double lengthLowerLeg = 0.0;
          if (leftFoot != null)
            lengthLowerLeg =
                java.lang.Math.abs(leftFoot.getPosition(leftLower).y)
                    + java.lang.Math.abs(leftFoot.getBoundingBox(leftFoot).getMinimum().z);
          else
            lengthLowerLeg = java.lang.Math.abs(leftLower.getBoundingBox(leftLower).getMinimum().y);

          double diff = lengthSupportLeg - lengthLowerLeg;
          double angle =
              java.lang.Math.asin(java.lang.Math.abs(diff) / java.lang.Math.abs(posLower.y));

          if (lengthSupportLeg * 2.0 < lengthLowerLeg) {
            leftUpperFinalOrient = new edu.cmu.cs.stage3.math.Matrix33();
            leftLowerFinalOrient = new edu.cmu.cs.stage3.math.Matrix33();
            leftLowerFinalOrient.rotateX(0.25 * java.lang.Math.PI);
            leftFootFinalOrient = new edu.cmu.cs.stage3.math.Matrix33();
            leftFootFinalOrient.rotateX(-0.25 * java.lang.Math.PI);

            rightUpperFinalOrient = new edu.cmu.cs.stage3.math.Matrix33();
            rightLowerFinalOrient = new edu.cmu.cs.stage3.math.Matrix33();
            rightLowerFinalOrient.rotateX(-0.25 * java.lang.Math.PI);
            rightFootFinalOrient = new edu.cmu.cs.stage3.math.Matrix33();
            rightFootFinalOrient.rotateX(0.25 * java.lang.Math.PI);
          } else if (diff < 0) {
            leftUpperFinalOrient = new edu.cmu.cs.stage3.math.Matrix33();
            leftUpperFinalOrient.rotateX(-0.5 * java.lang.Math.PI - angle);
            leftLowerFinalOrient = new edu.cmu.cs.stage3.math.Matrix33();
            leftLowerFinalOrient.rotateX(0.5 * java.lang.Math.PI + angle);
            leftFootFinalOrient = new edu.cmu.cs.stage3.math.Matrix33();

          } else {
            leftUpperFinalOrient = new edu.cmu.cs.stage3.math.Matrix33();
            leftUpperFinalOrient.rotateX(-0.5 * java.lang.Math.PI + angle);
            leftLowerFinalOrient = new edu.cmu.cs.stage3.math.Matrix33();
            leftLowerFinalOrient.rotateX(0.5 * java.lang.Math.PI - angle);
            leftFootFinalOrient = new edu.cmu.cs.stage3.math.Matrix33();
          }
        }
      } else {
        if ((rightLower == null)) {
          leftUpperFinalOrient = new edu.cmu.cs.stage3.math.Matrix33();
          leftUpperFinalOrient.rotateX(0.5 * java.lang.Math.PI);
          leftFootFinalOrient = new edu.cmu.cs.stage3.math.Matrix33();
          leftFootFinalOrient.rotateX(0.5 * java.lang.Math.PI);

          rightUpperFinalOrient = new edu.cmu.cs.stage3.math.Matrix33();
          rightUpperFinalOrient.rotateX(0.5 * java.lang.Math.PI);
          rightFootFinalOrient = new edu.cmu.cs.stage3.math.Matrix33();
          rightFootFinalOrient.rotateX(0.5 * java.lang.Math.PI);

        } else {
          leftUpperFinalOrient = new edu.cmu.cs.stage3.math.Matrix33();
          leftLowerFinalOrient = new edu.cmu.cs.stage3.math.Matrix33();
          leftLowerFinalOrient.rotateX(0.5 * java.lang.Math.PI);
          leftFootFinalOrient = new edu.cmu.cs.stage3.math.Matrix33();
          leftFootFinalOrient.rotateX(0.5 * java.lang.Math.PI);
        }
      }
    }