## Math Intersection of two lines

Jun 5, 2012 at 2:56pm

# Math Intersection of two lines

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.

[attachment=195774,3986]

###### Attachments:
#53542
Jun 5, 2012 at 3:05pm
#192540
Jun 6, 2012 at 3:46am

[if \$f1>\$f5 && \$f3< \$f7 && \$f2>\$f4 && \$f6< \$f8 || \$f1<\$f5 && \$f3>\$f7 && \$f2>\$f4 && \$f6< \$f8 || \$f1>\$f5 && \$f3< \$f7 && \$f2<\$f4 && \$f6>\$f8 || \$f1< \$f5 && \$f3>\$f7 && \$f2< \$f4 && \$f6>\$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

#192541
Jun 6, 2012 at 1:30pm

Hi Roman,

your formular doesn´t work in my test Patch

– Pasted Max Patch, click to expand. –
#192542
Jun 6, 2012 at 3:00pm

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.

– Pasted Max Patch, click to expand. –
#192543
Jun 6, 2012 at 3:21pm

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

– Pasted Max Patch, click to expand. –
#192544
Jun 7, 2012 at 12:30am

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 < =.

:)

#192545
Jun 7, 2012 at 6:34am

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.

``````
----------begin_max5_patcher----------
1309.3ocyY8taaaCD+yt.8cfvHnXCHKPjTjRZHH.6EXXeuqvP1l1VcxTFRzd
tqcu66Ho9aJsshsrVQRjnHOd7386ti2w702+tISmmcTTLE8qnOhlL4qPOSL8
o6YRUGSltM93hz3BCgSWjscqPpl9X4fJwQkYf4wx0HUFZQb5h8owJwK0zrJS
pjwaEF59s7j3z5gj62lsWkJTFt6U0cxRCsYy+7ufC6vmhj+wvGr2S0TuKVsX
Shb8rbwBkc6D4CCiXdZpPQD8Sb3SdnO0ZgSjUqK1z4+992oeCud71UG+QtnP
nPXTwlr8oKQqSNHPPe6SgN+SY4vDS+EH0FXvj0aTUj7S3etlmoIRwhr8RCio
CiRkeMJUJOPqH47Hi9jYTt936fZc9dkJSdhMD1wFhTSqkP0W1IrBswvbZiD5
XeQvzVVKj5mC91RJ9aPXqE0Cw40HnRT3vJBDVUdgJKOds.0gjdC+tzVQmVa0
RS8FrLXbi+FIxXfDRuj+VUuEwGDKmAhDvoY58ZBf71PRSZThSltHMA7xZsfA
jHX4zOvX8S3650BXqUi0Fh8LXpV37rPcKx2EmCZRkHelPFOO0rg8rCVhxWEZ
uy3ieBXw2ArDdZXohWnoIRyqtcbVyaFEaviH6KqUtu2kQG6ZLaYrJt5PhVfh
YVyE4smBzYC0rGsaKtVJkYKAbsrQ4DAo.vCmTcbWZ7BAzx6IhWDiEoaEDxC3
LcKeJMj3aa4g8CNEa9RK1v8C73lovXggDcKL34aYSfO2zxMajF2.Mcde2C2y
.zawKTPrc3Cb8unOUplJsiNg1jbO0lDOX2eyZSVDXNQ9wQaV1dfCJ+6f.bhf
xnNi06nwTGt89mIZ7ik+cUQkKOWq7zsf9FTF75g3mkhPa+uFWHOCBzwFp1Ln
ZrFqpFCilwr1YMlJ1wZDs9dxfqX235X2c4VMaNGCODmtWjspp+VNnMKUZlbs
SijNTUgiTWClHOjTjTIvtn.RbLW0cUZr2u8Sm1JJJfyH+dy6JDuFvqw4ZXtF
cqA2ZLsFRGlLUBd6YpPNuOQnoX.Fy7JvCeAuBxPEWoU3i+Bsp6OCithNzY0Q
JyvmYRtCCwQXmUWENd46S8toD9ghVnr.SHn.B8Nm0+o8zFFbmDN3.OT9L.07
.rstHC7yGQejbXiHfiCHHJ5JhjvbUxKqGGydaG2V5tPLZsfKUDD6No0jWUhI
DWprKkYxsnlnQ1zRBG+.v4IR0.c4Tzq4dTJOChFvLu7ta2N0Ii7nsQPNNzFZ
fvCSTILYniJEXsa3V8kM1zcIpza9zH7McZDlwzQaI768sOYKmxQcNcGQVgGe
zQIZcjJWE1zphzSbMG72T8NkEcVULROphuYtG6N2dbQBmGn31H6F2VR.o9U6
Y43pjtu2hXsScxJzCqvu7vJF5Ce.ZRe9gUA1lDnWeaSNzaH5aeSS6yMz9xkn
0Meetg1WtDeeMspMBIbFuHsPf7bea2jAITDavyOprHhHt8HLqOaTuSL1RlYq
95+8KlUSOvqr.Jx1mWYJWUYDp05ANvpDYrJABb0PDqKQaRVBNmcrIWlTnsSW
1bmmNMI6sXQ5iXEL5hEl0G4h9+ibg6ibQFe4hzG4xe7kKZejK9nJWz9Z1iGW
0keejK73GlPmwzkEL9nKW793NpSscjAx9IWzeP0W9itb0qv85KNYjww9cLj2
nqu76CNdatikI8Dua2AQdQImsRDje6myL0Kvez9chz9skySyE5aK2NE88lX3
J73+.Wc3o1B
-----------end_max5_patcher-----------
``````
#192546

You must be logged in to reply to this topic.