Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Positioning Shape Inside of Ellipse

  1. Aug 15, 2012 #1
    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 [Broken]

    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: May 6, 2017
  2. jcsd
  3. Aug 16, 2012 #2

    chiro

    User Avatar
    Science Advisor

    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?
     
  4. Aug 16, 2012 #3
    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?
     
  5. Aug 16, 2012 #4

    chiro

    User Avatar
    Science Advisor

    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).
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Positioning Shape Inside of Ellipse
  1. Equation of Ellipse (Replies: 2)

  2. Ellipses on spheres (Replies: 0)

Loading...