Drawing a paraboloid with a rounded rectangle cross-section

249 Views Asked by At

The question explains it all, I'm looking for an equation that allows me to draw a paraboloid in 3D space with a rounded rectangle cross section across each value of Z.

The full explanation is as follows: I'm trying to make an app with a UI similar to that of the apple watch UI. The way that is done in this guide is by using an upside down paraboloid as the falloff for the size of the icons. Which leads to a size distribution across the screen that looks like this: Circle cross section

With the brightness value (0-->1) indicating how much icon would be scaled by if it were in that location. As you can see, because screens are rectangular, there is a lot of empty space in the corners I wish to get rid of.

I want something more like this:

enter image description here

Where the corners are more filled out (the straighter the rectangle the better of course)!

I've looked up equations, but all I could find was something that looked like a pyramid. That has a linear falloff. I want a shape that is curved like a paraboloid but with the cross section of a rounded rectangle. Any help would be greatly appreciated. Thanks!


Update: I tried Aretino's answer, and Aretino's answer with Rahul's suggestions and had some beautiful results. In the end though, I used Nominal Animal's response as the shape was just so clean and the falloff stretched to the corners of the rectangle, which I thought was very cool.

Here is what it looks like in a 3D Graph ($C_c = 0.9$):

3D Plotting of the graph

and here is what it looks like in practice in the app ($C_c = 1$):

App Screenshot

1

There are 1 best solutions below

5
On BEST ANSWER

Let $W$ be the width and $H$ be the height of your screen, $C_C$ a curvature exponent, $C_{MIN}$ being the minimum scaling factor ($0$), and $C_{MAX}$ the maximum ($1$). Then, the scaling factor at $(x, y)$ is $$C(x,y) = C_{MIN} + ( C_{MAX} - C_{MIN} ) \left ( \frac{ 16 x y ( W - x ) ( H - y ) }{ W^2 \, H^2 } \right )^{C_c}$$

With $C_c = 1/2$, the factor is overall high, and only drops near the edges. With $C_c = 2$, the factor changes $C^2$-smoothly to the edges (that is, even the rate of change changes smoothly).

Contours for C_c = 0.25, 0.5, 1.0, 2.0


@Aretino's suggestion as a comment to the question produces more "rectangular" shape, with corners having larger minimum scaling areas. Using the above definitions, (but with $C_c = 4$ or $C_c = 6$ per Aretino's suggestion), it is $$C(x,y) = C_{MAX} - (C_{MAX} - C_{MIN}) \left ( \left ( \frac{2 x - W}{W} \right )^{C_c} + \left ( \frac{2 y - H}{H} \right )^{C_c} \right )$$

Aretino's scaling function with exponent 4 and 6


@Rahul suggests further in a comment that taking the square root of the right parenthesized part in Aretino's suggestion yields parabolic falloff.