public LinearCurve(CurveDataModel model) : base(model) { Length = 0; for (int i = 1; i < model.ControlPoints.Count; i++) { Length += (model.ControlPoints[i] - model.ControlPoints[i - 1]).magnitude; } }
public BezierCurve(CurveDataModel model) : base(model) { Length = 0; Vector3 prevPoint = GetValue(0); List <float> lengthParts = new List <float>(); for (int i = 1; i <= lengthCalculationStepsCount; i++) { Vector3 curPoint = GetValue(i / (float)lengthCalculationStepsCount); lengthParts.Add((curPoint - prevPoint).magnitude); Length += lengthParts[i - 1]; prevPoint = curPoint; } fixedTimeIntervals.Add(0); for (int i = 0; i < lengthParts.Count; i++) { fixedTimeIntervals.Add(fixedTimeIntervals[i] + lengthParts[i] / Length); } }
protected AbstractCurve(CurveDataModel model) { this.model = model; }