cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

Tangent

Red
Advocate
I created a detail callout that includes editable hotspots so that you can move the circle and have the line follow. Now the problem I'm running into is when I move the circle upward in the Y direction the line crosses through the circle. (See attached picture)

I understand the reason behind the line going through the circle. The line end is determined by the radius of the circle and is added in the Y direction. Can someone please tell me if there is away for the line to stay tangent to that circle no matter what the size the circle maybe.


tan.jpg
Thanks,
Red
i7 8700k
ROG Strix Z390-E MoBo
64gb RAM
EVGA GeForce GTX 2080
_______________________
http://www.facebook.com/flatcreekdesignstn
http://www.sraarchitects.biz
4 REPLIES 4
Red
Advocate
Or is there away to have it act like the current line tool does.

(See attached picture)
Thanks,
Red
i7 8700k
ROG Strix Z390-E MoBo
64gb RAM
EVGA GeForce GTX 2080
_______________________
http://www.facebook.com/flatcreekdesignstn
http://www.sraarchitects.biz
I assume you mean perpendicular to the tangent, based on your picture.

You need to know the x, y of the circle center, and the x, y of the point where the line meets the horizontal line.

Let's call them cpX, cpY, epX, epY. (ep: end point)

You need to know the angle of that line. That's ng=ATN(rise/run) -> ng=ATN(ABS(cpY-epY)/ABS(cpX-epX)).

Once you know that angle, you can adjust the start point of the line:

(sp: start point, rds: radius)

spX=cpX+rds*COS(ng)
spY=cpY-rds*SIN(ng)

This is for the quadrant you show in your first picture. For the others, you'll need to change whether you add or subtract the rds*COS(ng) & rds*SIN(ng). You can find out what quadrant you're in by seeing which is greater of cpX/epX and cpY/epY. There's probably a better way, but my trig is not great and I can only find such things by trial and error. I build such things in +X, +Y first, then see what breaks when I go to other quadrants. The basic idea is right.

Then the line is LINE2 spX, spY, epX, epY, with a circle of CIRCLE2 cpX, cpY, rds.

HTH, (and hope I didn't make a mistake!)
James Murray

Archicad 27 • Rill Architects • macOS • OnLand.info
Red
Advocate
Thanks that was very helpful. And yes you are correct I should have said perpendicular to the tangent.
Thanks,
Red
i7 8700k
ROG Strix Z390-E MoBo
64gb RAM
EVGA GeForce GTX 2080
_______________________
http://www.facebook.com/flatcreekdesignstn
http://www.sraarchitects.biz
Durval
Enthusiast
Maybe it's simpler not to use the ABS inside the ATN.
The resulting angle from ATN function would be in range -90 to +90.
You then use the following code to convert it to the range -90 to 270 ('cvng' is the converted angle):

IF epX-cpX<0 THEN cvng=ng+180 ELSE cvng=ng

Notice that, for calculation of SINs and COSs, the range -90 to 270 is the same as the range 0 to 360 (e.g., SIN (-45) = SIN (315)).
This way, the script will 'know' the correct quadrant, by providing the proper negative or positive values for SINs and COSs.
But beware: you must provide a conditional calculation of 'ng' when epX=cpX, to avoid division by zero when calculating the ATN.
--- www.dtabach.com.br ---
AC 24 BR – MacBook Pro 2,9 GHz Intel Core i7 16GB RAM Mac OS 10.14