- #1

- 10

- 0

This is what I have so far (it's from C# code so I hope it's not too hard to understand).

1. Find this distance between the start and end points.

Code:

`float touchLength = Vector2.Distance (touchPoints [touch.fingerId] [0], touchPoints [touch.fingerId] [lastIndex]);`

Code:

`float slope = HelperFunctions.CalculateSlope (touchPoints [touch.fingerId] [0].x, touchPoints [touch.fingerId] [lastIndex].x, touchPoints [touch.fingerId] [0].y, touchPoints [touch.fingerId] [lastIndex].y);`

Code:

```
public static float CalculateSlope (float y1, float y2, float x1, float x2)
{
float slope = (y2 - y1) / (x2 - x1);
return slope;
}
```

4. Within the loop, create a point on the line and give it an x value based on the length of the line so that all points created will be equi-distant.

Code:

`perfectPoint.x = j * (touchLength / touchPoints [touch.fingerId].Count);`

5. Calculate the 'b' in 'y = mx + b' so we can figure what the corresponding y co-ordinate of perfectPoint.x.

Code:

`float b = HelperFunctions.CalculatePointOnLine (slope, touchPoints [touch.fingerId] [0].x, touchPoints [touch.fingerId] [0].y);`

Code:

```
public static float CalculatePointOnLine (float slope, float x, float y)
{
float b = y - (slope * x);
return b;
}
```

Thanks!