1
$\begingroup$

I'm trying to define a 2D "warp" function $y=f(x,w)$. A picture is worth a thousand bytes:

y=f(x,w)

I am looking for a simple function $f(x, w)$ that satisfies the following:

  • defined over $x = 0.0 \dots 1.0$
  • continuous
  • $f(0,w) = 0$,
  • $f(1,w) = 1$,
  • $f'(x,w) \ge 0$ (slope is never negative),
  • defines a straight line at $w=0$, i.e. $f(x,0) = x$ [but see note],
  • symmetrical about $y=-x+1$, i.e. $f(x,w) = 1-f(1-x,w)$,
  • slope at $x=0$ is the inverse of the slope at $x=1$: $f'(0,w) = 1/f'(1,w)$.

Note: despite what's shown in the graphic, I don't really care about the range of w: it could be -inf to inf (with y=x when w=0) or it could be 0 to 1 (with y=x when w=0.5). The important part is that the curve becomes sharper as w approaches its extreme values.

I suspect this is simple, but I haven't been able to crack it. Some kind of conic section, perhaps?

$\endgroup$
2
  • $\begingroup$ I didn't rigorously check all of the conditions for this, but would something like $f(x, w) = x^{e^w}$ work? $\endgroup$
    – cbishop
    Jan 27, 2015 at 17:27
  • $\begingroup$ @cbishop: mighty close!! but not symmetrical about y=-x+1. (OS X's Grapher app is my friend! :) $\endgroup$ Jan 27, 2015 at 18:13

2 Answers 2

3
$\begingroup$

You want a quadrant of a superellipse, appropriately transformed. That is to say, consider the family of curves $$x^m + y^m = 1,$$ for $m \in (0, \infty).$ Then your curve is merely the slightly modified case $$(1-x)^m + y^m = 1,$$ for $x \in [0,1]$, or equivalently, $$y = (1-(1-x)^m)^{1/m}.$$ Now all that remains is to reparametrize $m$ to $w$, for which $w = 0$ corresponds to $m = 1$, and $w(m) + w(1/m) = 0$. Your $w$ is underspecified, however; if I infer from your diagram that you would like $w \in (-1,1)$, then the following conditions give the function $$w(m) = \frac{m-1}{m+1}.$$ Therefore, your desired family of curves has the equation $$y = (1-(1-x)^{(1+w)/(1-w)})^{(1-w)/(1+w)}, \quad x \in [0,1], w \in (-1,1).$$


It would seem that this function does not have the property of being symmetric for $w$ and $-w$, so when I have a chance I will give it some more thought. But the family of curves is valid; it just needs re-parametrization.

$\endgroup$
1
  • $\begingroup$ Thanks for the lucid answer. As for the symmetry, I can cheat and use the curves produced by m=0...1, which cover half the cases. Then just flip around y=x for the other half. Let me know if you find a less hack-ish re-parametrization. $\endgroup$ Jan 27, 2015 at 18:33
1
$\begingroup$

Any Bezier Curve (parametric) with degree at least 2 and "symmetric & monotonic Bezier points on the edges of the unit square" will suffice. The degree will work as the needed "w" by swapping x, y.

One choice:

x = t^n;
y = 1-(1-t)^n; n >= 1, 0=< t =< 1.

$\endgroup$
1
  • $\begingroup$ A bezier vurve isn't the best answer. Consider NURBS instead $\endgroup$
    – Jean Marie
    Jan 31 at 23:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .