Sinova/Collisions

confusing example about Line

Closed this issue · 2 comments

I'm trying to use this package, but the example of how to create line is ambiguous:

If new Polygon(200, 5, [[-30, 0], [10, 20]]) is a line, why doesn't it only contains two point likes new Polygon(200, 5, [[-30, 0]]) ?
It looks likes a triangle.

You're confusing the 200, 5 as the first coordinate of the line, but it's actually the line's translation (or offset) within world-space.

new Polygon(200, 5, [[-30, 0], [10, 20]]) is creating a line segment from -30, 0 to 10, 20, and then translating that entire line by 200, 5 within the "world". This allows you to declare the point of the line/polygon as local points, and then move the entire line/polygon around by changing its x and y properties instead of having to loop through all of the points and add 200, 5 to them.

Think of 200, 5 as the "origin" of the shape around which the points are positioned, rotated, and scaled.

Let me know if this explanation makes sense. I can explain further if needed.

Thank you, that makes sense.