Exemplo n.º 1
0
  private Expression factor(Expression otherExpr) {
    if (!otherExpr.hasX2Coefficient() || otherExpr.isZero()) return null;

    Fraction x2 = otherExpr.getX2Coefficient();
    Fraction x1 = otherExpr.getXCoefficient();
    Fraction x0 = otherExpr.getConstant();

    Fraction a = expr.getXCoefficient();
    Fraction b = expr.getConstant();

    Fraction c = x2.divide(a);
    Fraction d = x0.divide(b);

    if (x1.equals(b.multiply(c).add(a.multiply(d)))) {
      return new Expression(c, d);
    }
    return null;
  }
Exemplo n.º 2
0
 private static int getTimeUnits(Fraction length, int tempo, int unitsInMinute) {
   int minute = 60 * unitsInMinute;
   int semibreveTime = 4 * minute / tempo;
   return length.multiply(semibreveTime).intValue();
 }