Re: what is the analytical function for this 2D shape?

From: lucy (losemind_at_yahoo.com)
Date: 08/15/04


Date: Sun, 15 Aug 2004 01:08:13 -0700


"Rouben Rostamian" <rouben@pc18.math.umbc.edu> wrote in message
news:cfmgr7$cfa$1@pc18.math.umbc.edu...
> In article <cfm9ng$jvs$1@news.Stanford.EDU>, lucy <losemind@yahoo.com>
wrote:
> >
> >I want to find an analytical function for the following 2D
> >shape, let me try to describe it:
> >
> >It is in the form of z=f(x, y).
> >
> >The top of this function should be flat and looks like a
> >rectangle, let's say the max height of this function is
> >z_max. Then the contour of f(x, y) at that height is like a
> >rectangle.
> >
> >The bottom of this function should look like a ellipse.
> >That's to say, the contour of f(x, y) at the height z=0 is
> >an ellipse.
> >
> >The aspect ratio for this ellipse will be in accordance
> >with the aspect ratio for the rectangle at the top.
> >
> >Basically, it is almost like an elliptical 2D gaussian
> >function being cut at some z-height, but the cut should be
> >morphed into rectangle.
>
> I think you meant a 3D shape rather than a 2D shape. The graph of
> z=f(x,y) is a surface in 3D.
>
> Anyway, let me paraphrase your question.
>
> You are looking for a function z=f(x,y) such that the curve
> f(x,y)=0 is an ellipse and the curve f(x,y)=h is a rectangle.
>
> Let's do a slightly more general problem because it makes it
> easier to see through the solution.
>
> Suppose the shape of the contour at the bottom of the graph (z=0) is
> described by the equation u(x,y) = 1.
>
> Suppose the shape of the contour at the top of the graph (z=h) is
> described by the equation v(x,y) = 1.
>
> Now pick z as either:
> z = f(x,y) = h [ u(x,y) - 1 ] / [ u(x,y) - v(x,y) ].
> or
> z = f(x,y) = h [ 1/u(x,y) - 1 ] / [ 1/u(x,y) - 1/v(x,y) ].
>
> With either choice we see that:
>
> z = 0 => u(x,y) = 1,
> z = h => v(x,y) = 1,
>
> as required. This solves the general problem.
>
>
> Now let's look at your specific problem.
>
> You want the bottom to be an ellipse. Therefore take:
>
> u(x,y) = x^2/a^2 + y^2/b^2.
>
> You want the top to be a rectangle. Therefore take:
>
> v(x,y) = |x/c + y/d| + |x/c - y/d|.
>
> Since you want the "aspect ratios" of the ellipse and rectangle to
> be the same, you want to take c/d = a/b. For example, try a=4, b=2,
> c=2, d=1.
>
> Then construct f(x,y) according to one or the other recipe above,
> whichever suits your needs.
>
> Note that these formulas make sense only for point (x,y) that lie in
> the region between the rectangle and the ellipse in the (x,y) plane.
> If you apply f(x,y) to points outside this region, you are on your own.
>
> If you have access to Maple, you can view the resulting surface by:
>
> restart;
> u := x^2/a^2 + y^2/b^2;
> v := abs(x/c+y/d) + abs(x/c-y/d);
> z := h*(1/u-1)/(1/u-1/v);
> h := 2; a := 4; b := 2; c := 2; d := 1;
> plot3d(z, x=-4..4, y=-2..2, view=0..h, grid=[50,50], style=patchnogrid,
> lightmodel=light4, shading=Z, scaling=constrained);
>
>
> --
> rr
>

Hi Rouben

Thank you very much for your help. Based on your answer, I made the
following conditional function:

z1(x, y)=((z(x, y)<=h).*z(x, y)+(z(x, y)>h).*h).*(u(x, y)<=1);

Basically, this sets all function values larger than h to be equal to h; and
all function values outside u(x, y)=1 to be 0(suppose the locus of u(x,
y)--bottom-- is always larger than the locus of v(x, y)--top).

It did work! Great! Thank you so much!

I just want ask: Does this method generate the simplest of such functions?
Because I am going to use these kind of function intensively in numerical
computations, I hope this function can be the most simple/efficient one to
compute(least time...)

Second, what if I want to have the Integrate(z1(x, y), for all (x, y) within
u(x, y)=1) to be 1?

What additional constraints can be put on the parameters a, b, c, d and h?

Thank you so much for your help!

-Lucy



Relevant Pages