public TAlgebraicNumber Determinant(Direction <TAlgebraicNumber> other) { if (other is null) { throw new ArgumentNullException(nameof(other)); } var a = _calculator.Multiply(X, other.Y); var b = _calculator.Multiply(Y, other.X); return(_calculator.Subtract(a, b)); }
public static bool IsStrictlySmallerThan <TAlgebraicNumber>( this IAlgebraicNumberCalculator <TAlgebraicNumber> calculator, TAlgebraicNumber number1, TAlgebraicNumber number2) { if (calculator is null) { throw new ArgumentNullException(nameof(calculator)); } return(calculator.IsStrictlyPositive(calculator.Subtract(number2, number1))); }
public static bool AreEqual <TAlgebraicNumber>( this IAlgebraicNumberCalculator <TAlgebraicNumber> calculator, TAlgebraicNumber number1, TAlgebraicNumber number2) { if (calculator is null) { throw new ArgumentNullException(nameof(calculator)); } return(calculator.IsZero(calculator.Subtract(number2, number1))); }
public static bool AreClose <TAlgebraicNumber>( this IAlgebraicNumberCalculator <TAlgebraicNumber> calculator, TAlgebraicNumber number1, TAlgebraicNumber number2, TAlgebraicNumber tolerance) { if (calculator is null) { throw new ArgumentNullException(nameof(calculator)); } var absoluteDifference = calculator.Abs(calculator.Subtract(number2, number1)); return(calculator.IsSmallerThan(absoluteDifference, tolerance)); }
public Direction <TAlgebraicNumber> DirectionTo(Point <TAlgebraicNumber> target) => new Direction <TAlgebraicNumber>( _calculator, _calculator.Subtract(target.X, X), _calculator.Subtract(target.Y, Y));