The Global ARCHICAD Community

Stay informed. Get help. Share your knowledge.

Everything about GDL - Doors/Windows/Objects/Stairs etc. (Example: I created an object that prints an error message in 3D all the time, please help!)

Moderators: Karl Ottenstein, LaszloNagy, ejrolon, Barry Kelly, gkmethy, Gergely Feher

By JGoode
#295387
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!
User avatar
By Lingwisyer
#295400
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.

Code: Select allIf ( 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-tric ... calc-macro

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



Ling.
User avatar
By Lingwisyer
#295472
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

Code: Select allcall "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.