about LCD

Baller Black's icon

I’m a beginner, ask everyone

This patch is used to control the servo motor of cnc.

I made a black line to walk randomly in the LCD.

Can it walk only in irregular shape areas, such as pink triangles?

Or when black lines pass through different color areas, there will be different signal outputs.

If I can, I will be able to set different color areas on the LOD so that the black lines can walk in the designated area.

thanks in advance

Baller Black's icon

Max Patch
Copy patch and select New From Clipboard in Max.

Floating Point's icon

interesting problem. I found this which might be of help:
http://totologic.blogspot.com/2014/01/accurate-point-in-triangle-test.html
if you are only using triangles try the barycentric coordinate system to determine if the a point in time is inside or outside the triangle

Floating Point's icon

here's one approach to one aspect of your problem(s):

Max Patch
Copy patch and select New From Clipboard in Max.

it only works with triangles though. It may be of help if you can make the line change direction when it goes outside of the boundary
adapted from the link I provided earlier

Baller Black's icon

fantastic, so amazing. let me take some time to study it. thank you very much.

Floating Point's icon

here's another way of checking if a point is inside or outside. This works for any polygon, not just triangles:

Max Patch
Copy patch and select New From Clipboard in Max.

Baller Black's icon

It's really powerful, thanks very much!