public bool BelongsTo(DirectionRange <TAlgebraicNumber> directions)
        {
            if (directions is null)
            {
                throw new ArgumentNullException(nameof(directions));
            }

            if (Equals(directions.Start) || Equals(directions.End))
            {
                return(true);
            }

            return(!(directions.IsShortestRange() ^ BelongsToShortestRange(directions)));
        }
Esempio n. 2
0
 internal Arc(
     IAlgebraicNumberCalculator <TAlgebraicNumber> calculator,
     Point <TAlgebraicNumber> center,
     DirectionRange <TAlgebraicNumber> directions,
     TAlgebraicNumber radius,
     Point <TAlgebraicNumber> start,
     Point <TAlgebraicNumber> end,
     Direction <TAlgebraicNumber> startTangentDirection,
     Direction <TAlgebraicNumber> endTangentDirection,
     Fraction weight)
     : base(calculator, start, end, startTangentDirection, endTangentDirection, weight)
 {
     Center     = center ?? throw new ArgumentNullException(nameof(center));
     Directions = directions ?? throw new ArgumentNullException(nameof(directions));
     Radius     = radius ?? throw new ArgumentNullException(nameof(radius));
 }
        public Arc <TAlgebraicNumber> CreateArc(
            Point <TAlgebraicNumber> center,
            DirectionRange <TAlgebraicNumber> directions,
            TAlgebraicNumber radius,
            Fraction weight)
        {
            if (center is null)
            {
                throw new ArgumentNullException(nameof(center));
            }

            if (directions is null)
            {
                throw new ArgumentNullException(nameof(directions));
            }

            if (radius is null)
            {
                throw new ArgumentNullException(nameof(radius));
            }

            var start = center.Translate(directions.Start, radius);
            var end   = center.Translate(directions.End, radius);

            var startNormalDirection  = directions.Start.NormalDirection();
            var startTangentDirection = directions.Orientation == Orientation.Clockwise
                ? startNormalDirection.Opposite()
                : startNormalDirection;

            var endNormalDirection  = directions.End.NormalDirection();
            var endTangentDirection = directions.Orientation == Orientation.Clockwise
                ? endNormalDirection.Opposite()
                : endNormalDirection;

            return(new Arc <TAlgebraicNumber>(
                       AlgebraicNumberCalculator,
                       center,
                       directions,
                       radius,
                       start,
                       end,
                       startTangentDirection,
                       endTangentDirection,
                       weight));
        }
        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);
        }