public void Visualize(IEnumerable <RateAtDate> data, int numPoints) { const string LinearFile = "Lin.csv"; const string CosineFile = "Cos.csv"; const string CubicFile = "Cub.csv"; DateTime start = data.First().Date; LinearInterpolation lin = new LinearInterpolation(data); CosineInterpolation cos = new CosineInterpolation(data); CubicInterpolation cub = new CubicInterpolation(data); using (StreamWriter linsw = new StreamWriter(fileRoot + LinearFile)) using (StreamWriter cossw = new StreamWriter(fileRoot + CosineFile)) using (StreamWriter cubsw = new StreamWriter(fileRoot + CubicFile)) { double increment = ((double)(data.Last().Date - data.First().Date).TotalMilliseconds) / (double)numPoints; for (int i = 0; i < numPoints; i++) { DateTime writeDate = start + TimeSpan.FromMilliseconds((i * increment)); linsw.WriteLine(lin.GetRate(writeDate)); cossw.WriteLine(cos.GetRate(writeDate)); cubsw.WriteLine(cub.GetRate(writeDate)); } } ShowData(fileRoot + LinearFile); ShowData(fileRoot + CosineFile); ShowData(fileRoot + CubicFile); }
public void Initialise(List <CamNode> points, int loops, CamTarget target) { if (points.Count == 1) { throw new CamStudioException("At least two points are required"); } var iterations = loops == 0 ? 1 : loops == 1 ? 2 : 3; SizeOfIteration = 1D / iterations; var size = points.Count * iterations; if (iterations > 1) { size++; } var xPoints = new double[size]; var yPoints = new double[size]; var zPoints = new double[size]; var yawPoints = new double[size]; var pitchPoints = new double[size]; var rollPoints = new double[size]; var fovPoints = new double[size]; var saturationPoints = new double[size]; var sepiaPoints = new double[size]; for (var j = 0; j < iterations; j++) { for (var i = 0; i < points.Count; i++) { xPoints[i + j * points.Count] = points[i].X; yPoints[i + j * points.Count] = points[i].Y; zPoints[i + j * points.Count] = points[i].Z; yawPoints[i + j * points.Count] = points[i].Yaw; pitchPoints[i + j * points.Count] = points[i].Pitch; rollPoints[i + j * points.Count] = points[i].Roll; fovPoints[i + j * points.Count] = points[i].FieldOfView; saturationPoints[i + j * points.Count] = points[i].Saturation; sepiaPoints[i + j * points.Count] = points[i].Sepia; } } if (iterations > 1) { xPoints[points.Count * iterations] = points[0].X; yPoints[points.Count * iterations] = points[0].Y; zPoints[points.Count * iterations] = points[0].Z; yawPoints[points.Count * iterations] = points[0].Yaw; pitchPoints[points.Count * iterations] = points[0].Pitch; rollPoints[points.Count * iterations] = points[0].Roll; fovPoints[points.Count * iterations] = points[0].FieldOfView; saturationPoints[points.Count * iterations] = points[0].Saturation; sepiaPoints[points.Count * iterations] = points[0].Sepia; } _xSpline = new CosineInterpolation(xPoints); _ySpline = new CosineInterpolation(yPoints); _zSpline = new CosineInterpolation(zPoints); _yawSpline = new CosineInterpolation(yawPoints); _pitchSpline = new CosineInterpolation(pitchPoints); _rollSpline = new CosineInterpolation(rollPoints); _fovSpline = new CosineInterpolation(fovPoints); _saturationSpline = new CosineInterpolation(saturationPoints); _sepiaSpline = new CosineInterpolation(sepiaPoints); }