Home › Forums › Problems and solutions in GDL › Others › BasicGeometricCalc Intersect_circle_line bad results
Tagged: BasicGeometricCalc
 This topic has 8 replies, 3 voices, and was last updated 3 years, 6 months ago by Péter Baksa.

AuthorPosts


July 11, 2019 at 19:01 #4838John PetersonParticipant
I’ve been starting to use the geometric calculator for GDL scripts. My first attempt worked great for finding the intersection of two circles.
My next attempt at finding the intersection of a line and a circle does not work. The line starts at .5,0 and the vector directional point is .5,1. The circle center points are 0,0 and the radius is 1.5. Below, you can see I have drawn the circle, the line, and had the calculator provide the two intersection points. It’s a bit hard to see, but they hotspots do not fall on the circle as they should. I’m using 22 but have not installed the latest patch that just became available last week. Haven’t had time to comb through the release notes. Snip of the code is below.
(from master script) INTERSECT_CIRCLE_LINE = 5
(from 2d script)
line2 .5, 0, .5, 1
circle2 0, 0, 1.5call “BasicGeometricCalc” PARAMETERS iFunction=INTERSECT_CIRCLE_LINE,
xo=0,
yo=0,
ro=1.5,
linePx=.5,
linePy=0,
lineVx=.5,
lineVy=1,
RETURNED_PARAMETERS ipx1,ipy1,ipx2,ipy2,stateif state=2 then
hotspot2 ipx1,ipy1
hotspot2 ipx2,ipy2
endifif state=1 then
hotspot2 ipx1,ipy1
endifAttachments:
Many thanks, JP

July 12, 2019 at 04:56 #4840Lingwisyer GCParticipant
I have never used it, but is it suppose to work with line extensions? Even if the return is that your lines do not intersect.
Ling.
Edit: Ah. Reading the documentation it is circle to vector, so it is suppose to work.
AC1823 AUS 4006
Selftaught, bend it till it breaks.
Win7  E5620 x 2  24GB  K2200 
July 12, 2019 at 07:26 #4841Lingwisyer GCParticipant
Is there any change if your line is not orthogonal?
AC1823 AUS 4006
Selftaught, bend it till it breaks.
Win7  E5620 x 2  24GB  K2200 
July 12, 2019 at 08:41 #4842Péter BaksaKeymaster
Hi,
each input “direction vector” of BasicGeometricCalc has to be a unit vector (length = 1.0 meter). You get a unit vector by dividing each coordinate with the length.
The returned vectors are unit vectors too.Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SE 
July 16, 2019 at 15:15 #4848John PetersonParticipant
I did make my vector exactly 1 meter from the reference point. It obviously does not work, and if the input needs to be something else that involves extra math, that’s just plain stupid.
Many thanks, JP

July 16, 2019 at 16:14 #4849Péter BaksaKeymaster
Hi John,
The vector is not the endpoint of the vector, just the vector itself. So in your case if (0.5, 0) and (0.5, 1) are two points on the line, the vector is (0, 1).
BasicGeometricCalc can return the unit vector between two points:
call "BasicGeometricCalc" parameters iFunction = 1, Point1X = toX, Point1Y = toY, Point1Z = toZ, Point2X = fromX, Point2Y = fromY, Point2Z = fromZ, returned_parameters Vx, Vy, Vz, distance
Vx, Vy, Vz will be the unit vector, and distance will be the distance between Point1 and Point2.
Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SE
July 16, 2019 at 20:38 #4850John PetersonParticipant
Thank you Peter!! That is exactly it. Thanks for taking the time to set me straight.
Many thanks, JP
Many thanks, JP

July 17, 2019 at 12:27 #4852John PetersonParticipant
Good morning Peter! May I impose upon you again for an explanation? I’m now using the DIRECTION_SEGMENT function because I can’t use a curve in a tube path. I have the start, end, and included angle of the arc segment as shown in the diagram. I provided a tolerance. I used vardim1 to see how many items were in the array. The result was 6. I followed the instructions to find the various x,y coordinates. The resulting points are nowhere near to points on that curve, or the curve inverted. They don’t have any reference to the curve whatsoever. What i did notice as the distance from the origin to point one and the same to point two was exactly 1 meter. The distance to the third point was not. Can you offer a bit of advice please?
Strike that. I found the problem. The code is wrong on the website. It lists DIRECTION_SEGMENT as the function. The name sounded funny to me so i refereed to the index and there was one that made a lot more sense called SEGMENT_ARC. That worked perfectly. Can you please alert someone as to the error and also please tell them to make the pictures larger and more legible. They are almost impossible to read.
Many thanks, JP


July 18, 2019 at 07:32 #4855Péter BaksaKeymaster
Thank you, Using BasicGeometricCalc macro is updated with clickable image links.
Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SE


AuthorPosts
 The forum ‘Others’ is closed to new topics and replies.