Beispiel #1
0
        public static bool IsGreaterThan <TAlgebraicNumber>(
            this IAlgebraicNumberCalculator <TAlgebraicNumber> calculator,
            TAlgebraicNumber number1,
            TAlgebraicNumber number2)
        {
            if (calculator is null)
            {
                throw new ArgumentNullException(nameof(calculator));
            }

            return(calculator.IsNegative(calculator.Subtract(number2, number1)));
        }
        internal bool BelongsToShortestRange(DirectionRange <TAlgebraicNumber> directions)
        {
            var determinant = directions.Start.Determinant(directions.End);

            if (_calculator.IsStrictlyPositive(determinant))
            {
                return(_calculator.IsStrictlyPositive(directions.Start.Determinant(this)) &&
                       _calculator.IsStrictlyPositive(Determinant(directions.End)));
            }

            if (_calculator.IsNegative(determinant))
            {
                return
                    (_calculator.IsStrictlyNegative(directions.Start.Determinant(this)) &&
                     _calculator.IsStrictlyNegative(Determinant(directions.End)));
            }

            return(false);
        }
Beispiel #3
0
        internal bool IsShortestRange()
        {
            if (IsDegenerate())
            {
                return(false);
            }

            return(Orientation switch
            {
                Orientation.Clockwise =>
                _calculator.IsNegative(Start.Determinant(End)),

                Orientation.CounterClockwise =>
                _calculator.IsStrictlyPositive(Start.Determinant(End)),

                var orientation => throw new NotSupportedException(
                    "Only clockwise and counterclockwise arc orientations are supported, "
                    + $"but got {orientation}.")
            });