Adjustable hotspot - set boundaries to Ellipse & Circle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2020-03-24
11:10 AM
- last edited on
2022-09-26
10:52 PM
by
Daniel Kassai
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

Any help is much appreciated.
Thanks
Windows 10
- Labels:
-
Library (GDL)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2020-03-25 02:48 AM
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-28 AUS 3110 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win11 | R5 2600 | 16GB | GTX1660 |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2020-03-25 11:21 AM
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
Windows 10

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2020-03-26 02:50 AM
r = ( a.b ) / ( sqr ( a^2 . ( cos ( theta ))^2 + b^2 . ( sin ( theta ))^2 ))
And substitute
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 intovalues "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
Ling.
AC22-28 AUS 3110 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win11 | R5 2600 | 16GB | GTX1660 |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2020-03-26 11:39 AM

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
Windows 10
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2020-03-26 01:14 PM
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?"


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2020-03-27 02:33 AM
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-28 AUS 3110 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win11 | R5 2600 | 16GB | GTX1660 |

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2020-05-26 05:18 AM
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-28 AUS 3110 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win11 | R5 2600 | 16GB | GTX1660 |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2022-06-23 08:08 PM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2022-06-24 03:28 AM
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-28 AUS 3110 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win11 | R5 2600 | 16GB | GTX1660 |