@Override public String toString() { StringBuffer str = new StringBuffer(); str.append("###Flying Ball###\n"); str.append("bottomPosX: " + mBottomPos.x() + "\n"); str.append("bottomPosY: " + mBottomPos.y() + "\n"); str.append("flyingPosX: " + mFlyingPos.x() + "\n"); str.append("flyingPosY: " + mFlyingPos.y() + "\n"); str.append("flyingHeight: " + mFlyingHeight + "\n"); return str.toString(); }
/** @param point */ public void calculateDistanceToStart(final Coord point) { if (Double.isInfinite(mFlyingPos.x()) || Double.isInfinite(mFlyingPos.y())) { throw new IllegalArgumentException( "FlyingBall: calculateDistanceToPoint is not possible, before setting the flying Position."); } final double x2 = Math.pow(Math.abs(point.x() - mFlyingPos.x()), 2); final double y2 = Math.pow(Math.abs(point.y() - mFlyingPos.y()), 2); mDistance = Math.sqrt(x2 + y2); }
/** * @param aFlyPosition * @param camId */ public void setFlyPositionAndCalculateFlyingHeight(final Coord aFlyPosition, final int camId) { mFlyingPos = aFlyPosition; final double bfX = Math.abs(mFlyingPos.x() - mBottomPos.x()); final double bfY = Math.abs(mFlyingPos.y() - mBottomPos.y()); final double bf = Math.sqrt((bfX * bfX) + (bfY * bfY)); Cam cam = Def.cams.get(camId); final double cfX = Math.abs(mFlyingPos.x() - cam.x); final double cfY = Math.abs(mFlyingPos.y() - cam.y); final double cf = Math.sqrt((cfX * cfX) + (cfY * cfY)); mFlyingHeight = (Def.camHeight * bf) / (bf + cf); }
/** @return */ public double getFlyingPositionY() { return mFlyingPos.y(); }
/** @return */ public double getFlyingPositionX() { return mFlyingPos.x(); }
/** @return */ public double getBottomPositionY() { return mBottomPos.y(); }
/** @return */ public double getBottomPositionX() { return mBottomPos.x(); }