One option is to have an array of extraction functions that you could apply to points. Then you can use the LINQ Select overload, which takes Func<TInput, int, TOutput> , to generate the sequence of values โโyou want to add and add it to TimeLinePoints in this way.
// Possibly store this in a static variable somewhere var extractors = new Func<Point, float>[] { p => px, p => py, p => pz }; // Just do this once; store the result as a float for simplicity when dividing later. float frameSum = FrameCount.Sum(); foreach (var extractor in extractors) { TimeLinePoints.AddRange(Points.Select((point, index) => new Vector2D(index / frameSum, extractor(point)); }
(You could go even further using SelectMany potentially, but where I would start ...)
source share