|Aug15-12, 11:56 PM||#1|
Positioning Shape Inside of Ellipse
In a game I'm developing, I have an ellipse which contains a blue shape inside of it like follows:
In the picture, the curves of the blue shape have the exact same arc as the area of the ellipse that it mirrors.
In this game, the blue shape can be stretched horizontally or vertically at any time. When it is stretched, I'd like for the enclosing ellipse to be able to increase in size so that it can fit the newly resized blue shape with the exact amount of border space around the blue shape as in the picture above. This seems like something that should be simple, yet I'm having so much trouble with it.
I've tried two things so far, increasing the size of the ellipse by the same proportion that the blue shape increased. Problem with this is the boundaries also will increase proportionally and will be small if the shapes are small and large if they're large.
I've also tried increasing the ellipse by the same amount as the blue shape. For instance if the blue shape is stretched by 5 pts, then I try to stretch the ellipse by 5 pts. Problem with this is eventually the blue shape out grows the ellipse.
So anyway, I was wondering how this could be done, if it's even possible. It seems like something that should be easy, but I just can't wrap my head around this...
|Aug16-12, 01:04 AM||#2|
Hey MaTHRo and welcome to the forums.
One suggestion I have is to solve the inequality for the ellipse and the object itself. I'm assuming both have the same centre (i.e. the centre of both objects is the same).
The equation of an ellipse is ((x-c)/a)^2 + ((y-d)/b)^2 = 1 where (c,d) is the centre and (a,b) are the lengths of ellipse for the x-stretch and y-stretch respectively.
If you can model your shape as an equation with a centre, then you can solve for a and b variables for the ellipse and then you can re-create the right ellipse using an appropriate parameterization.
So before I can explain what this means, I need to know if you can give me the equations corresponding to the shape. It seems that the bottom sides of the object are flat but the other horizontal ones are not.
What we should do first is solve for the a and b for the ellipse when the inside is just a box. The thing is that has many solutions so you need to give the size of the box relative to the size of the ellipse.
In other words given the stretch sizes of the ellipse, what is the size of the boxes sides? Are they proportional and how so?
|Aug16-12, 11:52 AM||#3|
|Aug16-12, 07:25 PM||#4|
Positioning Shape Inside of Ellipse
Not the new centre, but the parameters for the stretch of the ellipse (i.e. the a and b parameters in the equation of the ellipse).
If you are stretching in only one direction and not in both then your values will not change proportionally. You also need to figure out if you want to keep the ratio between the stretch parameters a and b.
Basically, you decide how you want the stretch parameters to change as you change the width of your box and then solve for those parameters a and b. Once you have these (the centres don't change) you use a parameterization for the ellipse in terms of t to draw it (unless you simply give some graphics library the centre and the stretch values for a and b).
|Similar Threads for: Positioning Shape Inside of Ellipse|
|Ellipse inside a circle - intersection||Differential Geometry||12|
|Rectangle Inside An Ellipse||Advanced Physics Homework||5|
|positioning points inside a triangle||Differential Geometry||0|
|Calculus BC: Rectangle inside an ellipse||Calculus & Beyond Homework||11|
|Shape Shape-shifting strings... solids, liquids, and gasses||Beyond the Standard Model||2|