I honestly feel someone else will look at this and understand the issue right away, like I feel like it is glaringly obvious but somehow I don’t get it. I am simply trying to get a set of evenly set points that fall along a line between two points (b.x, b.y) and (c.x, c.y)
What am I missing here? The points are always offset from the line and they should fall on top. Why aren’t they aligned?
The value of amt is thrown off by starting i at b.x.
Printing out amt will show some values above 1.
Adding b.x to point() will put the dots on the line but not at the start.
To account for the offset, set i from zero to range and float range = c.x - b.x.
That will bring amt between 0 and 1.
Then add the starting x: point(i+b.x, bc);.
Also, since the solid line is drawn across the entire range, you could bring that outside of the loop.
This is the answer. It is the “i” starting at b.x as the problem because the “i” is reused in the numerator of amt! Totally makes sense, was the thing I was overlooking. Changing this line from:
float amt = i/(c.x-b.x);
to
float amt = (i-b.x)/(c.x-b.x);
makes it so the points overlay the line as they should.
I am big into the reference section! I definitely read those multiple times before asking the question. Unfortunately, I still wasn’t able to find my error.
This is basically what I ended up doing to build my file a couple days ago when I had the problem. But now I also see the problem with the original code. Many ways to solve an issue! Thanks!