Math Intersection of two lines

double_UG's icon

need a formula witch detreminates if two lines have a intersection.For example I want to take the Node-Objekt Node1=A1 Node2=A2 Node3=B1 Node4=B2
how can i calculate if there is a intercept point or not.
I hope you undersand my bad english.

greetings
thanx for any help.

3986.A1A2B1B2.jpg
jpg
Roman Thilenius's icon

[if $f1>$f5 && $f3$f4 && $f6$f7 && $f2>$f4 && $f6$f5 && $f3$f8 || $f1$f7 && $f2$f8 then 1 else 0]

variables/inputs:
A1 X = $f1
A1 Y = $f2

A2 X = $f3
A2 Y = $f4

B1 X = $f5
B1 Y = $f6

B2 X = $f7
B2 Y = $f8

proposal done without max, pls check if it works right.

-110

double_UG's icon

Hi Roman,

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

your formular doesn´t work in my test Patch

seejayjames's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Try this one---the way you had the nodes pairs coming out, the [if] got evaluated before any node past 1 got into the expression. This one collects them all into a list first. It still doesn't work the way it was intended, but probably just a minor tweak needed. Regardless, you'll need to have the [if] evaluate this way, I think, because [nodes] sends out the values in order from node 1 upwards.

double_UG's icon
Max Patch
Copy patch and select New From Clipboard in Max.

that seems not to be the problem. look at the presets. preset 1 should give a 1 as preset 2 does.

Roman Thilenius's icon

he could use $f2 until $f9 - then inlet 1 can be use to evaluate by a bang.

and to make it theoretically more correct, it should be all >= and

:)

double_UG's icon
Max Patch
Copy patch and select New From Clipboard in Max.

look at the patch. if you make a "Cross" the result should be 1. If you move node 1 above node 2 you get the wrong result (0) see Preset 1. If node 1 is lower node 2 the result is right (1). so it seems to be a problem with the formular. since i don´t understand the formular i cant determinate whats wrong (i just copied it into my patch). Perhaps its a typing error. (it has not to be 100% correct so i dont need the >=
Any help is apprecitated.