Beispiel #1
0
 public FretLine(IEnumerable <FretSegment> segments)
 {
     _Segments = new List <FretSegment>(segments.OrderBy(s => s.String.Index));
     IsNut     = Segments.All(s => s.IsNut || s.IsVirtual);
 }
Beispiel #2
0
        public void ComputeFretShape()
        {
            VerifyIsStraight();
            //if (!IsStraight && !Layout.CompensateFretPositions && Layout.FretsTemperament == Physics.Temperament.Equal && CheckForHardBreak())
            //    return;

            var layout = Segments[0].String.Layout;

            if (Segments.Any(s => s.IsNut && !s.IsVirtual) && !Segments.All(s => s.IsNut || s.IsVirtual))
            {
                SeparateNutFromFrets();
                return;
            }

            if (IsStraight && Segments.Count > 1)
            {
                var leftBound  = layout.GetStringBoundaryLine(Segments.Last(fs => !fs.IsVirtual).String, FingerboardSide.Bass);
                var rightBound = layout.GetStringBoundaryLine(Segments.First(fs => !fs.IsVirtual).String, FingerboardSide.Treble);

                var line = Line.FromPoints(Segments.First().PointOnString.ToVector(), Segments.Last().PointOnString.ToVector());
                Points.Add(PointM.FromVector(line.GetIntersection(leftBound.Equation), UnitOfMeasure.Centimeters));
                Points.Add(PointM.FromVector(line.GetIntersection(rightBound.Equation), UnitOfMeasure.Centimeters));
            }
            else
            {
                if (Layout.FretInterpolation == FretInterpolationMethod.Spline && StringCount >= 2)
                {
                    foreach (var seg in Segments.Where(s => !s.IsVirtual || s.String.HasFret(s.FretIndex)))
                    {
                        Points.Add(seg.PointOnString);
                    }

                    InterpolateSplineV2(1d / (Segments.Count * 2.2));

                    ExtendToBorders();
                }
                else if (Layout.FretInterpolation == FretInterpolationMethod.NotchedSpline && StringCount >= 2)
                {
                    foreach (var seg in Segments.Where(s => !s.IsVirtual || s.String.HasFret(s.FretIndex)))
                    {
                        //Points.Add(seg.PointOnString + (seg.Direction * Measure.Mm(1.5)));
                        Points.Add(PointM.Average(seg.P2, seg.PointOnString));
                        //Points.Add(seg.PointOnString);
                        Points.Add(PointM.Average(seg.P1, seg.PointOnString));
                        //Points.Add(seg.PointOnString + (seg.Direction * -1 * Measure.Mm(1.5)));
                    }

                    InterpolateSpline(0.33, 0.4);

                    ExtendToBorders();
                }
                else
                {
                    foreach (var seg in Segments.Where(s => !s.IsVirtual))
                    {
                        Points.Add(seg.PointOnString);
                    }
                    ExtendToBorders();
                }

                (Points as ObservableCollectionEx <PointM>).Reverse();

                if (Points.Count == 2)
                {
                    _IsStraight = true;
                }
            }
        }
Beispiel #3
0
 public bool AllSegmentsAreClosed()
 {
     return(Segments.All(s => s.IsOpen == false));
 }
Beispiel #4
0
 public bool IsEmpty()
 {
     return(Segments.All(s => s.Type == ElementType.None) && PowerLines.Count() == 0);
 }
Beispiel #5
0
 private bool _areAllSegmentsHit() => Segments.All(x => x.IsHit);