Stay informed. Get help. Share your knowledge.

### Adjustable hotspot - set boundaries to Ellipse & Circle

Topics specific to the scripting and development of Library Parts and Libraries using Param-O or the Geometric Description Language – GDL. (Example: How do you use “REQUEST” GDL commands?)

### Adjustable hotspot - set boundaries to Ellipse & Circle#308690

By JGoode
#308690
Hello,

I have an object that uses 0, 0 as the centre point (so the 4 maximum points are -a/2, a/2, b/2, -b/2).

I have a node that I don't want to be able to move outside of my ellipse / circle (Think tree trunk moving under a canopy, wouldn't be able to put the trunk outside of the canopy ). I don't know if anyone has had to do this so has the code / calculations to hand? or if there's an ArchiCAD object that can do this?

Any help is much appreciated.

Thanks

### Re: Adjustable hotspot - set boundaries to Ellipse & Circle#308726

By Lingwisyer
#308726
Point on a circle is:

Code: Select all
``x^2 + y^2 = r^2``

Point on an eclipse is:

Code: Select all
``x^2 / ( x_max )^2 + y^2 / ( y_max )^2 = 1``

Where x_max and y_max are the extremities of your eclipse.

If x_max = y_max then you have a circle and the equation is the same as the first one here.

Following that:

Code: Select all
``````IF x^2 / ( x_max )^2 + y^2 / ( y_max )^2 # 1 then			!false return equation of an eclipse
theta = arctan ( y / x )							!angle of selected points
r = ( a.b ) / ( sqr ( a^2 . ( cos ( theta ))^2 +  b^2 . ( sin ( theta ))^2 ))	!radius at any given point
x = r . cos ( theta )							!x point of ecplise with given angle
y = r . sin ( theta )							!y point of ecplise with given angle
endIF``````

Ling.
Last edited by Lingwisyer on Tue May 26, 2020 4:13 am, edited 1 time in total.

### Re: Adjustable hotspot - set boundaries to Ellipse & Circle#308735

By JGoode
#308735
Thanks so much for your reply. I think I follow... is x_max equivalent to my A/2?

How would I then implement this into
Code: Select all
``````values "pos_x" range [ , ]
values "pos_y" range [ , ]``````
lines? That's where I'm really struggling with it.

Many thanks again

### Re: Adjustable hotspot - set boundaries to Ellipse & Circle#308800

By Lingwisyer
#308800
I missed a line in my original post:

Code: Select all
``````r = ( a.b ) / ( sqr ( a^2 . ( cos ( theta ))^2 +  b^2 . ( sin ( theta ))^2 ))
``````

And substitute arctan for atn.

JGoode wrote: Wed Mar 25, 2020 11:21 am Thanks so much for your reply. I think I follow... is x_max equivalent to my A/2?

If A.B is the bounding box of your eclipse, then x_max . y_max is indeed your A/2 . B/2

JGoode wrote: Wed Mar 25, 2020 11:21 am How would I then implement this into
Code: Select all
``````values "pos_x" range [ , ]
values "pos_y" range [ , ]``````
lines? That's where I'm really struggling with it.

You are wanting to give a list of all possible integer values for a given eclipse? So the user inputs the bounding box, then can select a point within an eclipse that is bound by that?

Code: Select all
``````(+-) A/2 + cx = pos_x			!cx = center x offset
(+-) B/2 + cy = pos_y			!cy = center y offset``````

Insert that however... I have not used the Range value before.

Ling.

### Re: Adjustable hotspot - set boundaries to Ellipse & Circle#308820

By JGoode
#308820
Wow, that's very helpful, gives a bit more context behind the r!

What I'm trying to do is set the absolute minimum and maximum that pos_x and pos_y can be so when I move the hotspot, it can't be dragged outside of the circle / ellipse.

Hope that makes sense.

Thanks

### Re: Adjustable hotspot - set boundaries to Ellipse & Circle#308823

By Braza
#308823
Hi JGoode,

If I were in your situation, I would just leave the parameters with no boundaries, and create a trigger with a print message. if the user put the trunk outside the canopy (-a/2<ParamX<a/2 and -b/2<ParamY<b/2), the following message would appear "ARE YOU KIDDING ME?"

### Re: Adjustable hotspot - set boundaries to Ellipse & Circle#308859

By Lingwisyer
#308859
JGoode wrote:What I'm trying to do is set the absolute minimum and maximum that pos_x and pos_y can be so when I move the hotspot, it can't be dragged outside of the circle / ellipse.

If there is not a need to tell the user what those limits are, you can just use my first post. If the equation for your eclipse is false, it will solve the intersection point between a line defined by cxcy . xy and your eclipse.

ie. If A > B then A = B

equation.jpg (137.77 KiB) Viewed 618 times

Ling.

### Re: Adjustable hotspot - set boundaries to Ellipse & Circle#311308

By Lingwisyer
#311308
Seeing you post over on the GDL forum, I just realised that your restriction was WITHIN the ellipse, not ON the ellipse...

So the first line would be GREATER THAN instead of NOT EQUAL

Code: Select all
``IF x^2 / ( x_max )^2 + y^2 / ( y_max )^2 > 1 ``

Hope that did not mess you up,
Ling.