Exemple #1
0
        /// <summary>
        /// Constructor.
        ///
        /// Generates a list of cores based on the given parameters.
        /// </summary>
        /// <param name="laminations">A list of laminations to create cores out of.</param>
        /// <param name="stackRange">IterableRange representing the range of stacks to create with.</param>
        /// <param name="fluxRange">IterableRange representing the range of stacks to create with.</param>
        /// <param name="stackingFactor">Stacking factor of the core.</param>
        /// <param name="destructionFactor">Destruction factor of the core.</param>
        /// <param name="excitationFactor">Excitation factor of the core.</param>
        /// <param name="tubeWindowMargin">Tube Window Margin to be used in the core.</param>
        /// <param name="func">Optional parameter, a function delegate that returns a boolean, and takes two integer inputs. As of 03/15/2019 only used with <see cref="Optimizer.IncrementCurrentProcessProgress(int, int)"/>.</param>
        protected internal CoreFactory(List <Lamination> laminations, RangeDouble stackRange, RangeDouble fluxRange, double stackingFactor, double destructionFactor, double excitationFactor, double tubeWindowMargin, Func <int, int, bool> func = null)
        {
            if ((stackRange.MinValue != stackRange.MaxValue) && stackRange.StepSize == 0)
            {
                throw new NoCoresFound("Stack has different minimum and maximum values with a step size of zero.");
            }
            int i             = 0;
            int maxIterations = fluxRange.Iterations * stackRange.Iterations * laminations.Count;

            Cores = new List <Core>();
            fluxRange.NextRange = stackRange;
            while (true)
            {
                try
                {
                    foreach (var lam in laminations)
                    {
                        Cores.Add(new Core(lam, stackRange.CurrentValue, fluxRange.CurrentValue, tubeWindowMargin, stackingFactor, destructionFactor, excitationFactor));
                        func?.Invoke(++i, maxIterations);
                    }
                    fluxRange.IncrementValue();
                }
                catch (IterationFinishedException) { break; }
            }
        }
Exemple #2
0
        /// <summary>
        /// The UpdateBarModelsData.
        /// </summary>
        /// <param name="barChartModel">The barChartModel<see cref="BarChartViewModel"/>.</param>
        /// <param name="barValuesModels">The barValuesModels<see cref="IList{BarValuesModel}"/>.</param>
        /// <param name="positionIndex">The positionIndex<see cref="int"/>.</param>
        public static void UpdateBarModelsData(this BarChartViewModel barChartModel, IList <BarValuesModel> barValuesModels, int positionIndex)
        {
            var barModels = barChartModel.BarModels;

            if (barModels.Count != barValuesModels.Count)
            {
                throw new ArgumentException($"{nameof(UpdateBarModelsData)} Error: {nameof(barModels)} and {nameof(barValuesModels)} count is not equal.");
            }
            var min = double.MaxValue;
            var max = double.MinValue;

            for (var i = 0; i < barModels.Count; i++)
            {
                var barModel    = barModels[i];
                var valuesModel = barValuesModels[i];
                barModel.IsSuspended = true;
                barModel.Index       = valuesModel.RankSteps[positionIndex];
                var offset      = barChartModel.SortDirection == System.ComponentModel.ListSortDirection.Descending ? barModel.Index - valuesModel.RanksInterpolated[positionIndex] : valuesModel.RanksInterpolated[positionIndex] - barModel.Index;
                var indexOffset = offset * barModel.BarContainerHeight;

                /// Prevent the first winner is drawn outside the area.
                if (barModel.Index == barModels.Count - 1 && indexOffset < 0)
                {
                    indexOffset = 0;
                }

                barModel.IndexOffset = indexOffset;
                barModel.BarOpacity  = 1 - (Math.Sin(offset.Abs() * Math.PI) * 0.7);
                var value = valuesModel.ValuesInterpolated[positionIndex];
                if (value < 0)
                {
                    value = 0;
                }

                barModel.Value = valuesModel.ValuesInterpolated[positionIndex];
                if (min > barModel.Value)
                {
                    min = barModel.Value;
                }

                if (max < barModel.Value)
                {
                    max = barModel.Value;
                }
            }

            if (min >= max || barChartModel.IsVisibleRangeFromZero)
            {
                min = 0;
            }

            var visibleRange = new RangeDouble(min, max);

            for (var i = 0; i < barModels.Count; i++)
            {
                barModels[i].VisibleRange = visibleRange;
                barModels[i].IsSuspended  = false;
            }
        }
        /// <summary>
        /// The GenerateDummyData.
        /// </summary>
        /// <param name="viewModel">The viewModel<see cref="BarChartViewModel"/>.</param>
        private void GenerateDummyData(BarChartViewModel viewModel)
        {
            viewModel.Title    = "Bar Chart Test App";
            viewModel.Subtitle = "Show Bar Chart with Dummy Data";
            var n     = 5;
            var range = new RangeDouble(0, 1000);

            for (var i = 0; i < n; i++)
            {
                var model = new BarModel {
                    Index = i, Name = $"Bar Test {i}", Value = (n - i) * (range.Length() / n), VisibleRange = range
                };
                viewModel.BarModels.Add(model);
            }
        }
        public void Range()
        {
            var range = RangeDouble.Range(0, 1);

            range.Length.Should().Be(2);
            range[0].Should().Be(0);
            range[1].Should().Be(1);

            range = RangeDouble.Range(-1, 2);
            range.Length.Should().Be(4);
            range[0].Should().Be(-1);
            range[1].Should().Be(0);
            range[2].Should().Be(1);
            range[3].Should().Be(2);
        }
Exemple #5
0
        public static PointParamWithRayProjection ClosestPointToRay(this ICurve curve, PointDirection3 ray, double tol = 1e-9)
        {
            var bound       = curve.Domain();
            int numOfRadius = 0;

            double[]  radius   = null;
            MathPoint location = null;

            var radiusResult       = curve.FindMinimumRadius();
            var domain             = new RangeDouble(curve.Domain());
            var tessTol            = radiusResult.Radius / 10;
            var closestPointOnEdge = Vector3.Zero;

            for (var i = 0; i < 1; i++)
            {
                var tessPoints = Sequences
                                 .LinSpace(domain.Min, domain.Max, 100)
                                 .Select(curve.PointParamAt).ToList();
                var edges = tessPoints.Buffer(2, 1).Where(buf => buf.Count == 2)
                            .ToList();

                var closestEdge
                    = edges
                      .Select(edge => new { edge, connection = MakeEdge(edge).ShortestEdgeJoining(ray, tol) })
                      .MinBy(o => o.connection.LengthSquared)[0];

                var a = closestEdge.edge[0].T;
                var b = closestEdge.edge[1].T;
                domain  = new RangeDouble(a, b);
                tessTol = tessTol / 10;
            }

            Func <Vector3, Vector3> projectOnRay = p => (p - ray.Point).ProjectOn(ray.Direction) + ray.Point;

            var solver = new BrentSearch(t =>
            {
                var p    = curve.PointAt(t);
                var proj = projectOnRay(p);
                return((p - proj).LengthSquared());
            }, domain.Min, domain.Max);

            solver.Minimize();
            var minT = solver.Solution;

            var pointParam = curve.PointParamAt(minT);

            return(new PointParamWithRayProjection(pointParam, projectOnRay(pointParam.Point)));
        }
Exemple #6
0
        public static IEnumerable <SearchItem> Range(SearchExpressionContext c)
        {
            var range = new RangeDouble();
            var alias = c.ResolveAlias("Range");

            foreach (var sr in c.args[0].Execute(c))
            {
                if (GetRange(sr, ref range))
                {
                    break;
                }
                else
                {
                    yield return(null);
                }
            }

            if (!range.valid)
            {
                if (c.args.Length < 2)
                {
                    c.ThrowError("No expression to end range");
                }
                foreach (var sr in c.args[1].Execute(c))
                {
                    if (GetRange(sr, ref range))
                    {
                        break;
                    }
                    else
                    {
                        yield return(null);
                    }
                }
            }

            if (!range.valid)
            {
                c.ThrowError("Incomplete range");
            }

            for (double d = range.start.Value; d < range.end.Value; d += 1d)
            {
                yield return(EvaluatorUtils.CreateItem(d, alias));
            }
        }
        /// <summary>
        /// The MoveInsideContainer
        /// </summary>
        /// <param name="range">The range<see cref="RangeDouble"/></param>
        /// <param name="container">The container<see cref="RangeDouble"/></param>
        /// <returns>The <see cref="RangeDouble"/></returns>
        public static RangeDouble MoveInsideContainer(this RangeDouble range, RangeDouble container)
        {
            if (container.Contains(range))
            {
                return(range);
            }

            var length = range.Length();

            if (length > container.Length())
            {
                length = container.Length();
            }

            var rangeInside = range.Start < container.Start ? new RangeDouble(container.Start, container.Start + length) : new RangeDouble(container.End - length, container.End);

            return(rangeInside);
        }
        // Draw the property inside the given rect
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            // First get the attribute since it contains the range for the slider
            RangeDouble range = attribute as RangeDouble;

            // Now draw the property as a Slider or an IntSlider based on whether it's a float or integer.
            if (property.propertyType == SerializedPropertyType.Float)
            {
                EditorGUI.Slider(position, property, (float)range.Min, (float)range.Max, label);
            }
            else if (property.propertyType == SerializedPropertyType.Integer)
            {
                EditorGUI.IntSlider(position, property, (int)range.Min, (int)range.Max, label);
            }
            else
            {
                EditorGUI.LabelField(position, label.text, "Use Range with float or int.");
            }
        }
Exemple #9
0
        /// <summary>
        /// The Interpolate.
        /// </summary>
        /// <param name="models">The models<see cref="IList{BarValuesModel}"/>.</param>
        /// <param name="resolution">The resolution<see cref="int"/>.</param>
        public static void Interpolate(this IList <BarValuesModel> models, int resolution)
        {
            var xs = RangeDouble.Range(0, (models.First().Values.Length * 2) - 1);

            foreach (var valuesModel in models)
            {
                var stepRanks             = valuesModel.Ranks.ExtendArray(2);
                var ranksForInterpolation = valuesModel.Ranks.ExtendSingleLinearInterpolatedArray();
                valuesModel.Times  = valuesModel.Times.ExtendArray(2);
                valuesModel.Values = valuesModel.Values.ExtendSingleLinearInterpolatedArray();

                var ranksSpline  = new NaturalSpline(xs, ranksForInterpolation, resolution);
                var valuesSpline = new NaturalSpline(xs, valuesModel.Values, resolution);
                valuesModel.RanksInterpolated  = ranksSpline.interpolatedYs;
                valuesModel.RankSteps          = stepRanks.ExtendArray(resolution);
                valuesModel.Times              = valuesModel.Times.ExtendArray(resolution);
                valuesModel.ValuesInterpolated = valuesSpline.interpolatedYs;
            }
        }
        /// <summary>
        /// The Offset the range to the specified distance.
        /// </summary>
        /// <param name="range">The range<see cref="RangeDouble"/></param>
        /// <param name="distance">The distance<see cref="double"/></param>
        /// <param name="extentRange">The extentRange<see cref="RangeDouble"/></param>
        /// <returns>The <see cref="RangeDouble"/></returns>
        public static RangeDouble Offset(this RangeDouble range, double distance, RangeDouble extentRange)
        {
            var length = range.Length();

            if (extentRange.Length() < length)
            {
                length = extentRange.Length();
            }

            var start    = range.Start + distance;
            var end      = start + length;
            var newRange = new RangeDouble(start, end);

            if (extentRange.Contains(newRange))
            {
                return(newRange);
            }

            return(start < extentRange.Start
                ? new RangeDouble(extentRange.Start, extentRange.Start + length)
                : new RangeDouble(extentRange.End - length, extentRange.End));
        }
Exemple #11
0
        static bool GetRange(SearchItem item, ref RangeDouble range)
        {
            if (item == null)
            {
                return(false);
            }
            if (!range.start.HasValue)
            {
                if (Utils.TryGetNumber(item.value, out var rs))
                {
                    range.start = rs;
                }
            }
            else if (!range.end.HasValue)
            {
                if (Utils.TryGetNumber(item.value, out var re))
                {
                    range.end = re;
                }
            }

            return(range.valid);
        }
Exemple #12
0
        /// <summary>
        /// The Set.
        /// </summary>
        /// <param name="sender">The sender<see cref="INotifyPropertyChanged"/>.</param>
        /// <param name="propertyChanged">The propertyChanged<see cref="PropertyChangedEventHandler"/>.</param>
        /// <param name="field">The field<see cref="double"/>.</param>
        /// <param name="value">The value<see cref="double"/>.</param>
        /// <param name="range">The range<see cref="RangeDouble"/>.</param>
        /// <param name="propertyName">The propertyName<see cref="string"/>.</param>
        /// <param name="propertyNames">The propertyNames<see cref="string[]"/>.</param>
        /// <returns>The <see cref="bool"/>.</returns>
        public static bool Set(this INotifyPropertyChanged sender, PropertyChangedEventHandler propertyChanged, ref double field, double value, RangeDouble range, [CallerMemberName] string propertyName = null, params string[] propertyNames)
        {
            if (field.IsEqualTo(value))
            {
                return(false);
            }

            if (value.IsInRange(range.Start, range.End))
            {
                field = value;
            }

            propertyChanged?.Invoke(sender, new PropertyChangedEventArgs(propertyName));
            return(true);
        }
        public static Vector3[] GetTessPoints(this ICurve curve, double chordTol, double lengthTol, RangeDouble? domain = null)
        {
            bool isPeriodic;
            double end;
            bool isClosed;
            double start;
            if (domain == null)
                curve.GetEndParams(out start, out end, out isClosed, out isPeriodic);
            else
            {
                start = domain.Value.Min;
                end = domain.Value.Max;
            }

            var startPt = (double[]) curve.Evaluate2(start, 0);
            var midPt = (double[]) curve.Evaluate2((start + end)/2, 0);
            var endPt = (double[]) curve.Evaluate2(end, 0);
            var set0 = GetTessPotsAsVector3(curve, chordTol, lengthTol, startPt, midPt)
                .ToArray();

            var set1 = GetTessPotsAsVector3(curve, chordTol, lengthTol, midPt, endPt)
                .ToArray();


            return set0.Concat(set1.Skip(1)).ToArray();
        }
Exemple #14
0
        /// <summary>
        /// Constructor.
        ///
        /// Generates a list of laminations based on the given parameters.
        /// As of 03/15/2019 <paramref name="yokeRange"/> does nothing as the standard laminations have a supplied dimension and cut to length laminations will determine the yoke size using <see cref="Data.Constants.DetermineYoke(CoreShape, Phase, double)"/>
        /// </summary>
        /// <param name="rangeSkips">RangeCombinationSkips representing which combinations of grades and thickness should be skipped.</param>
        /// <param name="stdLaminationsRange">IterableRange representing if both standard and cut to length laminations should be created.</param>
        /// <param name="shapeRange">IterableRange representing the range of core shapes to create with.</param>
        /// <param name="phase">Which phase to create for.</param>
        /// <param name="gradeRange">IterableRange representing the range of grades to create with.</param>
        /// <param name="thicknessRange">IterableRange representing the range of thickness to create with.</param>
        /// <param name="tongueRange">IterableRange representing the range of tongues to create with.</param>
        /// <param name="yokeRange">IterableRange representing the range of yokes to create with.</param>
        /// <param name="windowWidthRange">IterableRange representing the range of window widths to create with.</param>
        /// <param name="windowHeightRange">IterableRange representing the range of window heights to create with.</param>
        /// <param name="func">Optional parameter, a function delegate that returns a boolean, and takes two integer inputs. As of 03/15/2019 only used with <see cref="Optimizer.IncrementCurrentProcessProgress(int, int)"/>.</param>
        protected internal LaminationFactory(RangeCombinationSkips <int> rangeSkips, RangeInteger stdLaminationsRange, RangeInteger shapeRange, Phase phase, RangeInteger gradeRange, RangeInteger thicknessRange, RangeDouble tongueRange, RangeDouble yokeRange, RangeDouble windowWidthRange, RangeDouble windowHeightRange, Func <int, int, bool> func = null)
        {
            if ((tongueRange.MinValue != tongueRange.MaxValue) && tongueRange.StepSize == 0)
            {
                throw new NoCoresFound("Tongue has different minimum and maximum values with a step size of zero.");
            }
            if ((windowWidthRange.MinValue != windowWidthRange.MaxValue) && windowWidthRange.StepSize == 0)
            {
                throw new NoCoresFound("Tongue has different minimum and maximum values with a step size of zero.");
            }
            if ((windowHeightRange.MinValue != windowHeightRange.MaxValue) && windowHeightRange.StepSize == 0)
            {
                throw new NoCoresFound("Tongue has different minimum and maximum values with a step size of zero.");
            }
            int i             = 0;
            int maxIterations = stdLaminationsRange.Iterations * shapeRange.Iterations * gradeRange.Iterations * thicknessRange.Iterations * tongueRange.Iterations * yokeRange.Iterations * windowWidthRange.Iterations * windowHeightRange.Iterations;

            Laminations = new List <Lamination>();
            windowHeightRange.NextRange = windowWidthRange;
            windowWidthRange.NextRange  = yokeRange;
            yokeRange.NextRange         = tongueRange;
            tongueRange.NextRange       = thicknessRange;
            thicknessRange.NextRange    = gradeRange;
            gradeRange.NextRange        = shapeRange;
            shapeRange.NextRange        = stdLaminationsRange;

            while (true)
            {
                try
                {
                    if (GetLaminationType(stdLaminationsRange.CurrentValue) == LaminationType.STANDARD)
                    {
                        if (GetGradeThickness(GetGrade(gradeRange.CurrentValue), thicknessRange.CurrentValue, out double thickness))
                        {
                            if (!rangeSkips.SkipValue(gradeRange.CurrentValue, thicknessRange.CurrentValue))
                            {
                                Laminations.AddRange(GetLaminations(GetCoreShape(shapeRange.CurrentValue), phase, GetGrade(gradeRange.CurrentValue), thickness, tongueRange.MinValue, tongueRange.MaxValue));
                            }
                        }
                        windowHeightRange.CurrentValue = windowHeightRange.MaxValue;
                        windowWidthRange.CurrentValue  = windowWidthRange.MaxValue;
                        yokeRange.CurrentValue         = yokeRange.MaxValue;
                        tongueRange.CurrentValue       = tongueRange.MaxValue;
                    }
                    else
                    {
                        if (GetGradeThickness(GetGrade(gradeRange.CurrentValue), thicknessRange.CurrentValue, out double thickness))
                        {
                            if (!rangeSkips.SkipValue(gradeRange.CurrentValue, thicknessRange.CurrentValue))
                            {
                                Laminations.Add(new Lamination(false, "Cut-to-length", GetCoreShape(shapeRange.CurrentValue), phase, GetGrade(gradeRange.CurrentValue), thickness, tongueRange.CurrentValue,
                                                               DetermineYoke(GetCoreShape(shapeRange.CurrentValue), phase, tongueRange.CurrentValue), windowWidthRange.CurrentValue, windowHeightRange.CurrentValue, 1, 1, 1, (double)GetMaterialDollarsPerPound(GetGrade(gradeRange.CurrentValue)), 0));
                            }
                        }
                    }
                    func?.Invoke(++i, maxIterations);
                    windowHeightRange.IncrementValue();
                }
                catch (IterationFinishedException) { break; }
            }
        }
Exemple #15
0
 public NoiseSelector(RangeDouble range, ISimplexNoise noise)
 {
     this.noise     = noise;
     this.rangeFrom = range.From;
     this.rangeTo   = range.To;
 }
Exemple #16
0
        /// <summary>
        /// Constructor.
        ///
        /// Generates a list of laminations based on the given parameters.
        /// As of 03/15/2019 <paramref name="yokeRange"/> does nothing as the standard laminations have a supplied dimension and cut to length laminations will determine the yoke size using <see cref="Data.Constants.DetermineYoke(CoreShape, Phase, double)"/>
        /// </summary>
        /// <param name="rangeLams">RangeLaminationDetails representing the range of laminations to iterate with.</param>
        /// <param name="phase">Which phase to create for.</param>
        /// <param name="tongueRange">IterableRange representing the range of tongues to create with.</param>
        /// <param name="yokeRange">IterableRange representing the range of yokes to create with.</param>
        /// <param name="windowWidthRange">IterableRange representing the range of window widths to create with.</param>
        /// <param name="windowHeightRange">IterableRange representing the range of window heights to create with.</param>
        /// <param name="func">Optional parameter, a function delegate that returns a boolean, and takes two integer inputs. As of 03/15/2019 only used with <see cref="Optimizer.IncrementCurrentProcessProgress(int, int)"/>.</param>
        protected internal LaminationFactory(RangeLaminationDetails rangeLams, Phase phase, RangeDouble tongueRange, RangeDouble yokeRange, RangeDouble windowWidthRange, RangeDouble windowHeightRange, Func <int, int, bool> func = null)
        {
            int i             = 0;
            int maxIterations = rangeLams.Iterations * tongueRange.Iterations * yokeRange.Iterations * windowWidthRange.Iterations * windowHeightRange.Iterations;

            Laminations = new List <Lamination>();
            windowHeightRange.NextRange = windowWidthRange;
            windowWidthRange.NextRange  = yokeRange;
            yokeRange.NextRange         = tongueRange;
            tongueRange.NextRange       = rangeLams;

            while (true)
            {
                try
                {
                    if (rangeLams.CurrentValue.IsStandard)
                    {
                        Laminations.AddRange(GetLaminations(rangeLams.CurrentValue.Shape, phase, rangeLams.CurrentValue.Grade, rangeLams.CurrentValue.Thickness, tongueRange.MinValue, tongueRange.MaxValue));
                        windowHeightRange.CurrentValue = windowHeightRange.MaxValue;
                        windowWidthRange.CurrentValue  = windowWidthRange.MaxValue;
                        yokeRange.CurrentValue         = yokeRange.MaxValue;
                        tongueRange.CurrentValue       = tongueRange.MaxValue;
                    }
                    else
                    {
                        Laminations.Add(new Lamination(false, "Cut-to-length", rangeLams.CurrentValue.Shape, phase, rangeLams.CurrentValue.Grade, rangeLams.CurrentValue.Thickness, tongueRange.CurrentValue,
                                                       DetermineYoke(rangeLams.CurrentValue.Shape, phase, tongueRange.CurrentValue), windowWidthRange.CurrentValue, windowHeightRange.CurrentValue, 1, 1, 1, (double)GetMaterialDollarsPerPound(rangeLams.CurrentValue.Grade), 0));
                    }
                    func?.Invoke(++i, maxIterations);
                    windowHeightRange.IncrementValue();
                }
                catch (IterationFinishedException) { break; }
            }
        }
 /// <summary>
 /// Lengthes the specified range.
 /// </summary>
 /// <param name="range">The range.</param>
 /// <returns>The length in double.</returns>
 public static double Length(this RangeDouble range)
 {
     return(range.End - range.Start);
 }
        public static PointParamWithRayProjection ClosestPointToRay(this ICurve curve, PointDirection3 ray, double tol = 1e-9)
        {
            var bound = curve.Domain();
            int numOfRadius = 0;
            double[] radius = null;
            MathPoint location = null;

            var radiusResult = curve.FindMinimumRadius();
            var domain = new RangeDouble(curve.Domain());
            var tessTol = radiusResult.Radius/10;
            var closestPointOnEdge = Vector3.Zero;
            for (var i = 0; i < 1; i++)
            {
                var tessPoints = Sequences
                    .LinSpace(domain.Min, domain.Max, 100)
                    .Select(curve.PointParamAt).ToList();
                var edges = tessPoints.Buffer(2, 1).Where(buf => buf.Count == 2)
                    .ToList();

                var closestEdge
                    = edges
                        .Select(edge => new {edge, connection= MakeEdge(edge).ShortestEdgeJoining(ray, tol)})
                        .MinBy(o=>o.connection.LengthSquared)[0];

                var a = closestEdge.edge[0].T;
                var b = closestEdge.edge[1].T;
                domain = new RangeDouble(a, b);
                tessTol = tessTol/10;
            }

            Func<Vector3, Vector3> projectOnRay = p => (p - ray.Point).ProjectOn(ray.Direction) + ray.Point;

            var solver = new BrentSearch(t =>
            {
                var p = curve.PointAt(t);
                var proj = projectOnRay(p);
                return (p - proj).LengthSquared();
            }, domain.Min, domain.Max);
            solver.Minimize();
            var minT = solver.Solution;

            var pointParam = curve.PointParamAt(minT);
            return new PointParamWithRayProjection(pointParam, projectOnRay(pointParam.Point));
        }
        /// <summary>
        /// The IsEmpty
        /// </summary>
        /// <param name="range">The range<see cref="RangeDouble"/></param>
        /// <returns>The <see cref="bool"/></returns>
        public static bool IsEmpty(this RangeDouble range)
        {
            var isEmpty = range.Start.IsZero() && range.End.IsZero();

            return(isEmpty);
        }
        /// <summary>
        /// The Contains
        /// </summary>
        /// <param name="container">The container<see cref="RangeDouble"/></param>
        /// <param name="range">The range<see cref="RangeDouble"/></param>
        /// <returns>The <see cref="bool"/></returns>
        public static bool Contains(this RangeDouble container, RangeDouble range)
        {
            var contains = range.Start.IsInRange(container.Start, container.End) && range.End.IsInRange(container.Start, container.End);

            return(contains);
        }
        /// <summary>
        /// The Center
        /// </summary>
        /// <param name="range">The range<see cref="RangeDouble"/></param>
        /// <returns>The <see cref="double"/></returns>
        public static double Center(this RangeDouble range)
        {
            var center = range.Start + range.Length() * 0.5;

            return(center);
        }
Exemple #22
0
 public static double Get(this RangeDouble d, RandomSource rand)
 {
     return(rand.NextDouble(d.Max - d.Min) + d.Min);
 }
Exemple #23
0
 public static double GetNormalDist(this RangeDouble d, RandomSource rand)
 {
     return(rand.NextNormalDist(d.Min, d.Max));
 }