cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

2024 Technology Preview Program:
Master powerful new features and shape the latest BIM-enabled innovations

GDL
About building parametric objects with GDL.

Adjustable hotspot - set boundaries to Ellipse & Circle

JGoode
Expert
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
ArchiCAD 23

Windows 10
9 REPLIES 9
Lingwisyer
Guru
Point on a circle is:

x^2 + y^2 = r^2

Point on an eclipse is:

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:

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.

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win10 | R5 2600 | 16GB | GTX1660
JGoode
Expert
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
values "pos_x" range [ , ]
values "pos_y" range [ , ]
lines? That's where I'm really struggling with it.

Many thanks again
ArchiCAD 23

Windows 10
Lingwisyer
Guru
I missed a line in my original post:


r = ( a.b ) / ( sqr ( a^2 . ( cos ( theta ))^2 +  b^2 . ( sin ( theta ))^2 ))

And substitute arctan for atn.

JGoode wrote:
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:
How would I then implement this into
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?

(+-) 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.

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win10 | R5 2600 | 16GB | GTX1660
JGoode
Expert
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
ArchiCAD 23

Windows 10
Anonymous
Not applicable
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?"
Lingwisyer
Guru
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




Ling.

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win10 | R5 2600 | 16GB | GTX1660
Lingwisyer
Guru
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

IF x^2 / ( x_max )^2 + y^2 / ( y_max )^2 > 1 

Hope that did not mess you up,
Ling.

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

This is super helpful in understanding the radius and angles of the ellipse! I'm personally looking to do something much more simple for a few objects Im editing. A few of the objects need just a curved line, and one needs a full ellipse.

How would the actual script of this ellipse look if I just wanted a 2D ellipse w/ fill capabilities? Would this just be plugging in the radius and x/y equations into something like a POLY_ command?

 

Thanks!

You cannot use the previous equations to draw an ellipse unless you are wanting just a straight line approximation using angular divisions or are actually just wanting something like a three point arch, maybe, since AC does not draw shapes based on equations but based on points and tangents. These equations are what you would use when you are defining hotspots in your object. You will have to stick with the suggestions in your other post regarding the actual drawing of the shape.

 

 

Ling.

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

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!