Positioning Shape Inside of Ellipse

  • Thread starter Thread starter MaTHFRo
  • Start date Start date
  • Tags Tags
    Ellipse Shape
Click For Summary
In the game development discussion, the user is trying to dynamically resize an enclosing ellipse to fit a blue shape that can stretch in various directions while maintaining a consistent border space. They have attempted two methods: increasing the ellipse's size proportionally with the blue shape and increasing it by a fixed amount, both of which failed to maintain the desired fit. A suggestion was made to model both shapes mathematically, using the ellipse's equation and the parameters for the blue shape to determine the appropriate dimensions for the ellipse. The conversation emphasizes the importance of keeping the center of both shapes aligned and adjusting the stretch parameters accordingly. The user is encouraged to derive the equations for the blue shape to accurately calculate the necessary adjustments for the ellipse.
MaTHFRo
Messages
6
Reaction score
0
In a game I'm developing, I have an ellipse which contains a blue shape inside of it like follows:

http://img6.imageshack.us/img6/9518/screenshot20120815at938.png

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...

Thanks,

MaTHFRo
 
Last edited by a moderator:
Physics news on Phys.org
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?
 
chiro said:
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?

Thanks for the response Chiro. Yes, the ellipse and the blue shape both share the same center. The width and height of the ellipse is 75.5 and 54.5. The width and height of the rectangular area of the blue shape is 42.98 and 39.51 (the width and height of the entire blue shape are 60.5 and 39.5 respectfully). So are you recommending that I find this equation for the blue shape, I can use it to find the new center, then I plug that into the equation of the ellipse, and somehow that will give me the size I need?
 
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

  • · Replies 49 ·
2
Replies
49
Views
5K
Replies
6
Views
2K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
10
Views
7K
Replies
65
Views
6K
  • · Replies 42 ·
2
Replies
42
Views
7K
  • · Replies 16 ·
Replies
16
Views
2K
  • · Replies 0 ·
Replies
0
Views
1K