public CurveSegment Transform(CurveSegment curveSegment) { var translatedSegments = from s in curveSegment.DataPoints.AsParallel() select new DataPoint(s.XCoordinate + _xTransformation, s.YCoordinate + _yTransformation); return new CurveSegment(translatedSegments); }
public static double SAD(CurveSegment a, CurveSegment b) { var aDataPoints = a.DataPoints; var bDataPoints = b.DataPoints; var aSegCount = aDataPoints.Count(); var bSegCount = bDataPoints.Count(); if (aSegCount != bSegCount) throw new ArgumentException("Curve Segment A must have as many datapoints as Curve Segment B"); return Enumerable.Range(0, aSegCount).AsParallel().Select(i => { return Math.Abs(aDataPoints.ElementAt(i).YCoordinate - bDataPoints.ElementAt(i).YCoordinate); }).Sum(); }
public CurveSegment Transform(CurveSegment curveSegment) { var dataPointsAsList = curveSegment.DataPoints.ToList(); var numDataPoints = dataPointsAsList.Count; if (numDataPoints < 3) throw new ArgumentException("Cannot have less than 3 data points"); var firstDataPoint = curveSegment.DataPoints.First(); var lastDataPoint = curveSegment.DataPoints.Last(); dataPointsAsList.RemoveAt(numDataPoints - 1); dataPointsAsList.RemoveAt(0); var allDataPoints = from n in dataPointsAsList.AsParallel() select SolveInverseCurve(new List<DataPoint> { firstDataPoint, n, lastDataPoint }); return _evaluationPredicate(allDataPoints); }
public Curve(CurveSegment segment) { _segments = new List<CurveSegment>(); _segments.Add(segment); }