# Interpolate.CatmullRom(UnityEngine.Vector3, UnityEngine.Vector3, UnityEngine.Vector3, UnityEngine.Vector3, float, float)

Here are the examples of the csharp api Interpolate.CatmullRom(UnityEngine.Vector3, UnityEngine.Vector3, UnityEngine.Vector3, UnityEngine.Vector3, float, float) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

## 1 Examples

19 View Source File : Interpolate.cs
Project Creator : 365082218

``````static IEnumerable<Vector3> NewCatmullRom<T>(IList nodes, ToVector3<T> toVector3, int slices, bool loop) {
// need at least two nodes to spline between
if (nodes.Count >= 2) {

// yield the first point explicitly, if looping the first point
// will be generated again in the step for loop when interpolating
// from last point back to the first point

int last = nodes.Count - 1;
for (int current = 0; loop || current < last; current++) {
// wrap around when looping
if (loop && current > last) {
current = 0;
}
// handle edge cases for looping and non-looping scenarios
// when looping we wrap around, when not looping use start for previous
// and end for next when you at the ends of the nodes array
int previous = (current == 0) ? ((loop) ? last : current) : current - 1;
int start = current;
int end = (current == last) ? ((loop) ? 0 : current) : current + 1;
int next = (end == last) ? ((loop) ? 0 : end) : end + 1;

// adding one guarantees yielding at least the end point
int stepCount = slices + 1;
for (int step = 1; step <= stepCount; step++) {
yield return CatmullRom(toVector3((T)nodes[previous]),
toVector3((T)nodes[start]),
toVector3((T)nodes[end]),
toVector3((T)nodes[next]),
step, stepCount);
}
}
}
}``````