LinearSpline.cs 738 B

1234567891011121314151617181920212223242526272829
  1. using UnityEngine;
  2. namespace ARLocation
  3. {
  4. public sealed class LinearSpline : Spline
  5. {
  6. public LinearSpline(Vector3[] points)
  7. {
  8. Points = (Vector3[])points.Clone();
  9. CalculateSegments(100);
  10. }
  11. public override void CalculateSegments(int n)
  12. {
  13. segmentCount = (Points.Length - 1);
  14. segments = new Curve[segmentCount];
  15. lengths = new float[segmentCount];
  16. Length = 0.0f;
  17. for (var i = 0; i < segmentCount; i++)
  18. {
  19. segments[i] = new Line(Points[i], Points[i + 1]);
  20. Length += segments[i].EstimateLength();
  21. lengths[i] = Length;
  22. }
  23. }
  24. }
  25. }