Example #1
0
 public void calc() {
   try {
     // 取得輸入區的字串, 轉成浮點數後除以角度換算單位
     double theta = Double.parseDouble(degree.getText()) / convert;
     // 計算三角函數值, 並將結果寫到各文字欄位中
     sintxt.setText(String.format("%.3f", Math.sin(theta)));
     costxt.setText(String.format("%.3f", Math.cos(theta)));
     tantxt.setText(String.format("%.3f", Math.tan(theta)));
   } catch (NumberFormatException e) {
     degree.setText(""); // 發生例外時清除輸入區內容
   }
 }
Example #2
0
  protected void recalcWarpAmount() {
    if (inRate == 0f) return;

    double omegaIn, omegaOut, warp, d1;
    ParamField ggWarp;

    omegaIn = pr.para[PR_INFREQ].val / inRate * Constants.PI2;
    omegaOut = pr.para[PR_OUTFREQ].val / inRate * Constants.PI2;
    d1 = Math.tan((omegaOut - omegaIn) / 2);
    warp =
        Math.max(
            -0.98,
            Math.min(0.98, d1 / (Math.sin(omegaIn) + Math.cos(omegaIn) * d1))); // DAFx2000 'b'

    ggWarp = (ParamField) gui.getItemObj(GG_WARP);
    if (ggWarp != null) {
      ggWarp.setParam(new Param(warp * 100, Param.FACTOR));
    }
  }