Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

intersection point of two lines

Hmooslechner
Moderator
i try to get the intersection point of two lines:

line2 x11, y11, x12, x12
line2 x21, y21, x22, y22

is there a simple solution for this?

I am not so settlet in vector mathematics.. and tried it over the angles but my brain now is boiling...

I hope someone can help - thanks forwarding..
AC5.5-AC27EduAut, PC-Win10, MacbookAirM1, MacbookM1Max, Win-I7+Nvidia
14 REPLIES 14
JGoode
Expert
Hello,

So this almost does what I want it to. However I want to be able to say if the lines DO intersect completely (I don't just mean parallel like this) then to do something. I can't work out how I can achieve it.

Basically I'd like to know if line2 x[1], y[1], x[2], y[2] and line2 x[3], y[3], x[4], y[4] cross over and if they do then show an error.

I don't know if this is achievable or not as I haven't found any solution to it online and this is as close to what I need to achieve as I've been able to find.

Thanks!
ArchiCAD 23

Windows 10
Jochen Suehlo
Moderator
I havent tried this, but maybe it could help, I am not shure:
http://gdl.graphisoft.com/tips-and-tricks/calling-basicgeometriccalc-macro
Jochen Suehlo . AC12-27 . MAC OSX 14.4 . WIN11
GDL object creation: b-prisma.de
Lingwisyer
Guru
If it is just if they intersect or not, regardless of where they actually intersect, can you just compare the slope ratio between your two lines? If they are equal, then they are parallel.

If ( x[1] + x[2] ) / ( y[1] + y[2] ) = ( x[3] + x[4] ) / ( y[3] + y[4] ) then else
...
I havent tried this, but maybe it could help, I am not shure:
http://gdl.graphisoft.com/tips-and-tricks/calling-basicgeometriccalc-macro

By the looks if it, that is a pretty convenient macro. It will give you the intersection coordinates too.



Ling.

AC22-28 AUS 3110Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win11 | R5 2600 | 16GB | GTX1660
JGoode
Expert
It's if the lines actually cross over and not if they cross over at some point if they were longer lines...
ArchiCAD 23

Windows 10
Lingwisyer
Guru
Well, using the same macro, you could just compare the vector intersection coordinates to your point to point? Can you use ranges? a < b < c

call "BasicGeometricCalc" parameters	iFunction	= INTERSECT_LINE_LINE,
					vx1		= vx1,
					vy1		= vy1,
					px1		= px1,
					py1		= py1,
					vx2		= vx2,
					vy2		= vy2,
					px2		= px2,
					py2		= py2,
 		returned_parameters	ipx,
					ipy,
					state

If State = 1 then
	If vx1 < ipx < vx2 & vy1 < ipy < vy2 & px1 < ipx < px2 & py1 < ipy < pvy2 then
		...
	endIf
endIf

Basically, if the intersection falls within the quadrangle formed by your line end points, then their line segments intersect.



Ling.

AC22-28 AUS 3110Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win11 | R5 2600 | 16GB | GTX1660