コード例 #1
0
ファイル: Multiple.java プロジェクト: micyee/granada
 /**
  * Fisher distribution
  *
  * @param f Fisher value
  * @param n1 N1 value
  * @param n2 N2 value
  * @return P-value associated
  */
 private static double FishF(double f, int n1, int n2) {
   double x = n2 / (n1 * f + n2);
   if ((n1 % 2) == 0) {
     return StatCom(1 - x, n2, n1 + n2 - 4, n2 - 2) * Math.pow(x, n2 / 2.0);
   }
   if ((n2 % 2) == 0) {
     return 1 - StatCom(x, n1, n1 + n2 - 4, n1 - 2) * Math.pow(1 - x, n1 / 2.0);
   }
   double th = Math.atan(Math.sqrt(n1 * f / (1.0 * n2)));
   double a = th / (Math.PI / 2.0);
   double sth = Math.sin(th);
   double cth = Math.cos(th);
   if (n2 > 1) {
     a = a + sth * cth * StatCom(cth * cth, 2, n2 - 3, -1) / (Math.PI / 2.0);
   }
   if (n1 == 1) {
     return 1 - a;
   }
   double c =
       4 * StatCom(sth * sth, n2 + 1, n1 + n2 - 4, n2 - 2) * sth * Math.pow(cth, n2) / Math.PI;
   if (n2 == 1) {
     return 1 - a + c / 2.0;
   }
   int k = 2;
   while (k <= (n2 - 1) / 2.0) {
     c = c * k / (k - .5);
     k = k + 1;
   }
   return 1 - a + c;
 }
コード例 #2
0
ファイル: Creature.java プロジェクト: jasonfong/animats
  public double bearingTo(Placeable p) {
    int xdist, ydist;
    double angle;
    double bearing;

    if (p == null) {
      return 0;
    }

    xdist = p.getX() - xcoord;
    ydist = p.getY() - ycoord;

    angle = Math.atan(((double) ydist) / xdist);
    angle = angle * 180 / Math.PI;

    if (angle < 0) {
      if (xdist < 0) {
        angle = 180 + angle; // 360 + angle - 180
      } else {
        angle = 360 + angle;
      }
    } else if (xdist < 0) {
      angle = 180 + angle;
    }

    if (angle > heading) {
      bearing = angle - heading;
    } else if (angle == heading) {
      bearing = 0;
    } else {
      bearing = angle + 360 - heading;
    }

    return bearing;
  }
コード例 #3
0
ファイル: Barrier.java プロジェクト: GeorgeBirch/CodeDay2016
 // Bharat's collision system
 public void bounce(Player b) {
   double trueAngle = Math.atan(b.getVel().getX() / b.getVel().getY());
   double incAngle = trueAngle + angle;
   double newAngle = incAngle + angle + Math.PI;
   Point p = new Point();
   p.x = (int) (b.VEL * Math.cos(newAngle));
   p.y = (int) (b.VEL * Math.sin(newAngle));
   b.setVel(p);
 }
コード例 #4
0
ファイル: Barrier.java プロジェクト: GeorgeBirch/CodeDay2016
  public Barrier(int xs1, int ys1, int xs2, int ys2) {
    this.x1 = xs1;
    this.y1 = ys1;
    this.x2 = xs2;
    this.y2 = ys2;
    int[] xray = {x1, x1 + 3, x2, x2 + 3};
    int[] yray = {y1, y1 + 3, y2, y2 + 3};
    poly = new Polygon(xray, yray, 4);

    angle = Math.atan((y1 - y2) / (x1 - x2));
  }
コード例 #5
0
  public static double calAlpha(double theta, double dec) {
    if (Math.abs(dec) + theta > 89.9) return 180;

    return (double)
        Math.toDegrees(
            Math.abs(
                Math.atan(
                    Math.sin(Math.toRadians(theta))
                        / Math.sqrt(
                            Math.cos(Math.toRadians(dec - theta))
                                * Math.cos(Math.toRadians(dec + theta))))));
  }
コード例 #6
0
ファイル: Arrow.java プロジェクト: simonhjsong/drawfbp
    void draw(Graphics2D g) {

      // toX/toY is tip of arrow and fx/fy is a point on the line -
      // fx/fy is used to determine direction & angle

      AffineTransform at = AffineTransform.getTranslateInstance(toX, toY);
      int b = 9;
      double theta = Math.toRadians(20);
      // The idea of using a GeneralPath is so we can
      // create the (three lines that make up the) arrow
      // (only) one time and then use AffineTransform to
      // place it anywhere we want.
      GeneralPath path = new GeneralPath();

      // distance between line and the arrow mark <** not **
      // Start a new line segment from the position of (0,0).
      path.moveTo(0, 0);
      // Create one of the two arrow head lines.
      int x = (int) (-b * Math.cos(theta));
      int y = (int) (b * Math.sin(theta));
      path.lineTo(x, y);

      // distance between line and the arrow mark <** not **
      // Make the other arrow head line.
      int x2 = (int) (-b * Math.cos(-theta));
      int y2 = (int) (b * Math.sin(-theta));
      // path.moveTo(0,0);
      path.lineTo(x2, y2);
      path.closePath();

      // theta is in radians
      double s, t;
      s = toY - fy; // calculate slopes.
      t = toX - fx;
      if (t != 0) {
        s = s / t;
        theta = Math.atan(s);
        if (t < 0) theta += Math.PI;
      } else if (s < 0) theta = -(Math.PI / 2);
      else theta = Math.PI / 2;

      at.rotate(theta);
      // at.rotate(theta,toX,toY);
      Shape shape = at.createTransformedShape(path);
      if (checkStatus == Status.UNCHECKED) g.setColor(Color.BLACK);
      else if (checkStatus == Status.COMPATIBLE) g.setColor(FOREST_GREEN);
      else g.setColor(ORANGE_RED);
      g.fill(shape);
      g.draw(shape);
    }
コード例 #7
0
  /* CALCULATE VALUES QUADRANTS: Calculate x-y values where direction is not
  parallel to eith x or y axis. */
  public static void calcValuesQuad(int x1, int y1, int x2, int y2) {
    double arrowAng = Math.toDegrees(Math.atan((double) haw / (double) al));
    double dist = Math.sqrt(al * al + aw);
    double lineAng =
        Math.toDegrees(Math.atan(((double) Math.abs(x1 - x2)) / ((double) Math.abs(y1 - y2))));

    // Adjust line angle for quadrant
    if (x1 > x2) {
      // South East
      if (y1 > y2) lineAng = 180.0 - lineAng;
    } else {
      // South West
      if (y1 > y2) lineAng = 180.0 + lineAng;
      // North West
      else lineAng = 360.0 - lineAng;
    }

    // Calculate coords
    xValues[0] = x2;
    yValues[0] = y2;
    calcCoords(1, x2, y2, dist, lineAng - arrowAng);
    calcCoords(2, x2, y2, dist, lineAng + arrowAng);
  }
コード例 #8
0
 public static void drawLine(Graphics g, int x1, int y1, int x2, int y2, int lineWidth) {
   if (lineWidth == 1) g.drawLine(x1, y1, x2, y2);
   else {
     double angle;
     double halfWidth = ((double) lineWidth) / 2.0;
     double deltaX = (double) (x2 - x1);
     double deltaY = (double) (y2 - y1);
     if (x1 == x2) angle = Math.PI;
     else angle = Math.atan(deltaY / deltaX) + Math.PI / 2;
     int xOffset = (int) (halfWidth * Math.cos(angle));
     int yOffset = (int) (halfWidth * Math.sin(angle));
     int[] xCorners = {x1 - xOffset, x2 - xOffset + 1, x2 + xOffset + 1, x1 + xOffset};
     int[] yCorners = {y1 - yOffset, y2 - yOffset, y2 + yOffset + 1, y1 + yOffset + 1};
     g.fillPolygon(xCorners, yCorners, 4);
   }
 }
コード例 #9
0
 public void onLivingUpdate() {
   if (flyToggleTimer > 0) {
     flyToggleTimer--;
   }
   if (worldObj.difficultySetting == 0
       && getEntityHealth() < getMaxHealth()
       && (ticksExisted % 20) * 12 == 0) {
     heal(1);
   }
   inventory.decrementAnimations();
   prevCameraYaw = cameraYaw;
   super.onLivingUpdate();
   landMovementFactor = speedOnGround;
   jumpMovementFactor = speedInAir;
   if (isSprinting()) {
     landMovementFactor += (double) speedOnGround * 0.29999999999999999D;
     jumpMovementFactor += (double) speedInAir * 0.29999999999999999D;
   }
   float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
   float f1 = (float) Math.atan(-motionY * 0.20000000298023224D) * 15F;
   if (f > 0.1F) {
     f = 0.1F;
   }
   if (!onGround || getEntityHealth() <= 0) {
     f = 0.0F;
   }
   if (onGround || getEntityHealth() <= 0) {
     f1 = 0.0F;
   }
   cameraYaw += (f - cameraYaw) * 0.4F;
   cameraPitch += (f1 - cameraPitch) * 0.8F;
   if (getEntityHealth() > 0) {
     List list =
         worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(1.0D, 0.0D, 1.0D));
     if (list != null) {
       for (int i = 0; i < list.size(); i++) {
         Entity entity = (Entity) list.get(i);
         if (!entity.isDead) {
           collideWithPlayer(entity);
         }
       }
     }
   }
 }
コード例 #10
0
 // To add/remove functions change evaluateOperator() and registration
 public double evaluateFunction(String fncnam, ArgParser fncargs) throws ArithmeticException {
   switch (Character.toLowerCase(fncnam.charAt(0))) {
     case 'a':
       {
         if (fncnam.equalsIgnoreCase("abs")) {
           return Math.abs(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("acos")) {
           return Math.acos(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("asin")) {
           return Math.asin(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("atan")) {
           return Math.atan(fncargs.next());
         }
       }
       break;
     case 'c':
       {
         if (fncnam.equalsIgnoreCase("cbrt")) {
           return Math.cbrt(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("ceil")) {
           return Math.ceil(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("cos")) {
           return Math.cos(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("cosh")) {
           return Math.cosh(fncargs.next());
         }
       }
       break;
     case 'e':
       {
         if (fncnam.equalsIgnoreCase("exp")) {
           return Math.exp(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("expm1")) {
           return Math.expm1(fncargs.next());
         }
       }
       break;
     case 'f':
       {
         if (fncnam.equalsIgnoreCase("floor")) {
           return Math.floor(fncargs.next());
         }
       }
       break;
     case 'g':
       {
         //              if(fncnam.equalsIgnoreCase("getExponent"   )) { return
         // Math.getExponent(fncargs.next());                } needs Java 6
       }
       break;
     case 'l':
       {
         if (fncnam.equalsIgnoreCase("log")) {
           return Math.log(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("log10")) {
           return Math.log10(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("log1p")) {
           return Math.log1p(fncargs.next());
         }
       }
       break;
     case 'm':
       {
         if (fncnam.equalsIgnoreCase("max")) {
           return Math.max(fncargs.next(), fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("min")) {
           return Math.min(fncargs.next(), fncargs.next());
         }
       }
       break;
     case 'n':
       {
         //              if(fncnam.equalsIgnoreCase("nextUp"        )) { return Math.nextUp
         // (fncargs.next());                } needs Java 6
       }
       break;
     case 'r':
       {
         if (fncnam.equalsIgnoreCase("random")) {
           return Math.random();
         } // impure
         if (fncnam.equalsIgnoreCase("round")) {
           return Math.round(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("roundHE")) {
           return Math.rint(fncargs.next());
         } // round half-even
       }
       break;
     case 's':
       {
         if (fncnam.equalsIgnoreCase("signum")) {
           return Math.signum(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("sin")) {
           return Math.sin(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("sinh")) {
           return Math.sinh(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("sqrt")) {
           return Math.sqrt(fncargs.next());
         }
       }
       break;
     case 't':
       {
         if (fncnam.equalsIgnoreCase("tan")) {
           return Math.tan(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("tanh")) {
           return Math.tanh(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("toDegrees")) {
           return Math.toDegrees(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("toRadians")) {
           return Math.toRadians(fncargs.next());
         }
       }
       break;
     case 'u':
       {
         if (fncnam.equalsIgnoreCase("ulp")) {
           return Math.ulp(fncargs.next());
         }
       }
       break;
       // no default
   }
   throw new UnsupportedOperationException(
       "MathEval internal function setup is incorrect - internal function \""
           + fncnam
           + "\" not handled");
 }
コード例 #11
0
ファイル: Arrow.java プロジェクト: springer126/jDevelop
  private int[] Translated_Point(double constant, int[] arrow_x, int[] arrow_y, double gradient) {
    double[] translated = new double[2];
    double[][] trans_matrix = new double[2][2];
    double ang_rot;
    double[] point2_temp = new double[4];
    int cnt, row, col;
    int[] pt = new int[2];

    translated[0] = 0.00;
    translated[1] = 0.00;
    trans_matrix[0][0] = 0.00;
    trans_matrix[0][1] = 0.00;
    trans_matrix[1][0] = 0.00;
    trans_matrix[1][1] = 0.00;
    point2_temp[0] = 0.00;
    point2_temp[1] = 0.00;
    point2_temp[2] = 0.00;
    point2_temp[3] = 0.00;
    cnt = 0;
    row = 0;
    col = 0;
    ang_rot = 0.00;

    // translate the line to the origin
    // thus the translated points to be found are:
    translated[0] = arrow_x[1];
    if (constant < 0) {
      translated[1] = arrow_y[1] + Math.abs(constant);
    } else {
      translated[1] = arrow_y[1] - Math.abs(constant);
    }

    // find the angle of rotation
    ang_rot = Math.atan(gradient);

    if ((end_x - start_x) == 0) {
      if (arrow_x[0] > 0) {
        translated[0] = arrow_x[1] - arrow_x[0];
      } else {
        translated[0] = arrow_x[1] + arrow_x[0];
      }
      translated[1] = arrow_y[1];
      trans_matrix[0][0] = -1;
      trans_matrix[0][1] = 0;
      trans_matrix[1][0] = 0;
      trans_matrix[1][1] = 1;
    } else {
      // declare the transformation matrix
      trans_matrix[0][0] = Math.cos(2 * ang_rot);
      trans_matrix[0][1] = Math.sin(2 * ang_rot);
      trans_matrix[1][0] = Math.sin(2 * ang_rot);
      trans_matrix[1][1] = Math.cos(2 * ang_rot) * (-1);
    }

    // multiply the transformation matrix with the point
    // store it in an array
    for (row = 0; row < 2; row++) {
      for (col = 0; col < 2; col++) {
        point2_temp[cnt] = trans_matrix[row][col] * translated[col];
        cnt++;
      }
    }

    if ((end_x - start_x) == 0) {
      if (arrow_x[0] > 0) {
        arrow_x[2] = (int) Math.round(point2_temp[0] + point2_temp[1] + arrow_x[0]);
      } else {
        arrow_x[2] = (int) Math.round(point2_temp[2] + point2_temp[1] - arrow_x[0]);
      }
      arrow_y[2] = (int) Math.round(point2_temp[2] + point2_temp[3]);
    } else {
      // from the array, get the reflected point
      arrow_x[2] = (int) Math.round(point2_temp[0] + point2_temp[1]);
      if (constant < 0) {
        arrow_y[2] = (int) Math.round(point2_temp[2] + point2_temp[3] - Math.abs(constant));
      } else {
        arrow_y[2] = (int) Math.round(point2_temp[2] + point2_temp[3] + Math.abs(constant));
      }
    }
    pt[0] = arrow_x[2];
    pt[1] = arrow_y[2];
    return pt;
  }
コード例 #12
0
ファイル: MapPanel.java プロジェクト: agale123/Catan
  public synchronized void paint(Graphics graphics) {

    Graphics2D g = (Graphics2D) graphics;

    Image water = Toolkit.getDefaultToolkit().getImage("catanui/water.jpg");
    g.drawImage(water, 0, 0, this);

    for (Hex o : _hexes) {
      o.paint(g, _display_offset[0], _display_offset[1]);
    }

    g.translate(_display_offset[0] + 2, _display_offset[1] - 1);
    synchronized (portContents) {
      for (Pair c : portContents.keySet()) {

        int lowx =
            hexleft
                + (((CoordPair) c.getA()).getX() - (((CoordPair) c.getA()).getX() % 2))
                    / 2
                    * intervalSide[0]
                + (((CoordPair) c.getA()).getX() - (((CoordPair) c.getA()).getX() % 2))
                    / 2
                    * intervalSide[1]
                + (((CoordPair) c.getA()).getX() % 2) * intervalSide[0];
        int lowy = hextop + ((CoordPair) c.getA()).getY() * intervalUp;
        int highx =
            hexleft
                + (((CoordPair) c.getB()).getX() - (((CoordPair) c.getB()).getX() % 2))
                    / 2
                    * intervalSide[0]
                + (((CoordPair) c.getB()).getX() - (((CoordPair) c.getB()).getX() % 2))
                    / 2
                    * intervalSide[1]
                + (((CoordPair) c.getB()).getX() % 2) * intervalSide[0];
        int highy = hextop + ((CoordPair) c.getB()).getY() * intervalUp;

        int dx = highx - lowx;
        int dy = highy - lowy;
        double rad = Math.atan((1.0) * dy / dx);

        if (dx < 0) rad += Math.PI;

        g.translate(lowx, lowy);
        g.rotate(rad);
        g.drawImage(
            BoardObject.images.get(BoardObject.type2port.get(portContents.get(c))), 0, -75, null);
        g.rotate(-rad);
        g.translate((-1) * lowx, (-1) * lowy);
      }
    }
    g.translate((-1) * _display_offset[0], (-1) * _display_offset[1]);

    synchronized (roadContents) {
      for (Pair c : roadContents.keySet()) {

        Road r =
            new Road(
                hexleft
                    + (((CoordPair) c.getA()).getX() - (((CoordPair) c.getA()).getX() % 2))
                        / 2
                        * intervalSide[0]
                    + (((CoordPair) c.getA()).getX() - (((CoordPair) c.getA()).getX() % 2))
                        / 2
                        * intervalSide[1]
                    + (((CoordPair) c.getA()).getX() % 2) * intervalSide[0],
                hextop + ((CoordPair) c.getA()).getY() * intervalUp);

        r.setX2(
            hexleft
                + (((CoordPair) c.getB()).getX() - (((CoordPair) c.getB()).getX() % 2))
                    / 2
                    * intervalSide[0]
                + (((CoordPair) c.getB()).getX() - (((CoordPair) c.getB()).getX() % 2))
                    / 2
                    * intervalSide[1]
                + (((CoordPair) c.getB()).getX() % 2) * intervalSide[0]);
        r.setY2(hextop + ((CoordPair) c.getB()).getY() * intervalUp);

        r.setColor(roadContents.get(c));
        r.paint(g, _display_offset[0], _display_offset[1]);
      }
    }

    synchronized (vertexContents) {
      for (CoordPair c : vertexContents.keySet()) {
        int newx =
            hexleft
                + ((c._x - (c._x % 2)) / 2 * intervalSide[0]
                    + (c._x - (c._x % 2)) / 2 * intervalSide[1]
                    + (c._x % 2) * intervalSide[0])
                - 20;
        int newy = hextop + c._y * intervalUp - 20;

        if ((BoardObject.type) (vertexContents.get(c).getA()) == BoardObject.type.SETTLEMENT) {
          Settlement s = new Settlement(newx, newy, (Integer) (vertexContents.get(c).getB()));
          s.paint(g, _display_offset[0], _display_offset[1]);
        } else if ((BoardObject.type) (vertexContents.get(c).getA()) == BoardObject.type.CITY) {
          City s = new City(newx, newy, (Integer) (vertexContents.get(c).getB()));
          s.paint(g, _display_offset[0], _display_offset[1]);
        } else System.out.println("neither -_-");
      }
    }

    g.setColor(Color.GRAY);
    g.fill(new Rectangle(0, 0, 110, 60));
    g.setColor(Color.LIGHT_GRAY);
    g.fill(new Rectangle(3, 3, 104, 56));
    if (_dieRoll > 0) {
      BufferedImage r1img =
          diceImage.getSubimage((int) (Math.floor((twoDice[0] - 1) * 94.7)), 0, 94, 93);
      g.drawImage(r1img, 5, 7, 48, 47, null);
      BufferedImage r2img =
          diceImage.getSubimage((int) (Math.floor((twoDice[1] - 1) * 94.7)), 0, 94, 93);
      g.drawImage(r2img, 55, 7, 48, 47, null);
    }

    if (_up != null) _up.paint(g);

    if (!_gameOver.equals("") && !_dismiss) {
      _currAlpha += 0.007;
    }
    g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, _currAlpha));
    g.setColor(Color.GRAY);
    g.fill(new Rectangle(-20, 0, 1020, 650));
    g.setColor(Color.BLACK);
    g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) 1.0));
    if (!_gameOver.equals("")) {

      if (_currAlpha >= 0.8) {
        if (_gameOver.equals(gameLogic._name)) {
          g.drawString("Congratulations, you won!", 350, 200);
        } else {
          g.drawString(_gameOver + " has won!", 350, 200);
        }
        _dismiss = true;
      } else repaint();
    }
  }
コード例 #13
0
ファイル: Atan.java プロジェクト: PrinzEugen7/Statistics
 public static void main(String[] args) {
   double deg = 30;
   double rad = Math.toRadians(deg);
   double ans = Math.atan(rad);
   System.out.println(ans);
 }
コード例 #14
0
ファイル: GuiHatSelection.java プロジェクト: KevCraftler/Hats
  public void drawPlayerOnGui(int par1, int par2, int par3, float par4, float par5) {
    if (stand != null) {
      RenderHelper.enableGUIStandardItemLighting();
      GlStateManager.enableColorMaterial();
      GlStateManager.pushMatrix();

      //	        GlStateManager.disableAlpha();

      GlStateManager.translate((float) par1, (float) par2, 50.0F);

      GlStateManager.translate(23F, -20.0F, 0.0F);
      GlStateManager.scale((float) (-par3), (float) par3, (float) par3);
      GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);

      GlStateManager.rotate(-80.0F, 0.0F, 1.0F, 0.0F);
      GlStateManager.rotate(-10.0F, 0.0F, 0.0F, 1.0F);
      //	        GlStateManager.rotate(-((float)Math.atan((double)(0.0F / 40.0F))) * 20.0F, 1.0F,
      // 0.0F, 0.0F);

      Minecraft.getMinecraft().getRenderManager().playerViewY = 180.0F;

      GlStateManager.translate(0.5D, 0.5D, 0.5D);
      GlStateManager.translate(0.0D, -0.5D, 0.0D);
      GlStateManager.rotate(
          -((float) Math.atan((double) (par4 / 40.0F))) * 20.0F, 0.0F, 1.0F, 0.0F);
      GlStateManager.rotate(
          -((float) Math.atan((double) (par5 / 40.0F))) * 20.0F, 0.0F, 0.0F, -1.0F);
      GlStateManager.translate(0.0D, 0.5D, 0.0D);
      if (stand.orientation == 0) {
        GlStateManager.rotate(180F, 0.0F, 1.0F, 0.0F);
      } else if (stand.orientation == 1) {
        GlStateManager.rotate(-90F, 0.0F, 1.0F, 0.0F);
      } else if (stand.orientation == 3) {
        GlStateManager.rotate(90F, 0.0F, 1.0F, 0.0F);
      }

      GlStateManager.enableNormalize();

      this.mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
      IBlockState state =
          HatStand.blockHatStand
              .getDefaultState()
              .withProperty(
                  BlockHatStand.TYPE,
                  stand.hasBase
                      ? stand.hasStand
                          ? stand.hatName.isEmpty() ? 0 : 1
                          : stand.isOnFloor ? 2 : EnumFacing.getFront(stand.sideOn).ordinal() + 2
                      : 3);
      RendererHelper.renderBakedModel(
          mc.getBlockRendererDispatcher().getBlockModelShapes().getModelForState(state), -1, null);

      GlStateManager.translate(-0.5D, -0.5D, -0.5D);

      HatInfoClient info = stand.info;

      if (tempInfo == null
          || info == null
          || !(tempInfo.hatName.equalsIgnoreCase(stand.hatName)
              && tempInfo.colourR == stand.colourR
              && tempInfo.colourG == stand.colourG
              && tempInfo.colourB == stand.colourB
              && tempInfo.alpha == stand.alpha)) {
        tempInfo =
            new HatInfoClient(
                stand.hatName, stand.colourR, stand.colourG, stand.colourB, stand.alpha);
      }

      stand.info = tempInfo;

      TileRendererHatStand.renderer.renderHatStand(stand, 0, 0, 0, 1.0F, -1, stand.gameProfile);

      stand.info = info;

      //	        GlStateManager.enableAlpha();

      GlStateManager.popMatrix();
      GlStateManager.disableRescaleNormal();
      OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
      GlStateManager.disableTexture2D();
      OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);

      RenderHelper.disableStandardItemLighting();
    }
  }
コード例 #15
0
 /**
  * Calculate Cumulative Cauchy distribution function.
  *
  * @return the probability that a stochastic variable x is less than X
  * @author Klaus Meffert
  * @since 1.1
  */
 public double nextCauchy() {
   return 0.5 + Math.atan((m_rn.nextDouble() - m_location) / m_scale) / Math.PI;
 }