Length between two points on an arbitrary surface

70 Views Asked by At

Given a surface represented by the function $f(x,y):R^2 \rightarrow R$. I am trying to write a program that computes the distance between two points that belongs to that surface.

For example, say, the surface is represented by $$f(x,y) = \dfrac{1}{\pi}\left(1 - \dfrac{x^2 + y^2}{2}\right)\exp\left(-\dfrac{x^2 + y^2}{2}\right)$$

And my points are $(-2,2, f(-2,2) )$ and $(2.2, 1.5, f(2.2,1.5))$, I am trying to compute the distance represented by the green line, which basically represents is like landing a tape on that surface between those two points

function f(x,y) example

My rusty math from college tells me that derivatives is the approach but not sure if that is in the right direction.

1

There are 1 best solutions below

1
On

Let $\tau:[0,1]\to \mathbb{R}^k$ be an arbitrary smooth function. We partition $0=t_0<\ldots<t_n=1$ and try to approximate the length of the curve as the sum of the length of the line segments between consecutive $\tau(t_i)$ points. We use $\|\cdot\|$ to denote the length of a vector in $\mathbb{R}^k$. Let $\tau_1,\ldots, \tau_k$ be the coordinate functions of $\tau$, so $\tau(t)=(\tau_1(t), \ldots, \tau_k(t))$.

We have $$\|\tau(t_i)-\tau(t_{i-1})\|^2 = \sum_{j=1}^k |\tau_j(t_i)-\tau_j(t_{i-1})|^2.$$ For a very fine partition, we will have, roughly, that $$\tau_j(t_i)-\tau_j(t_{i-1})\approx \tau'_j(t_i)[t_i-t_{i-1}].$$ Therefore we have an approximation of the length as $$\sum_{i=1}^n \sqrt{\sum_{j=1}^k \tau'_j(t_i)^2}\cdot [t_i-t_{i-1}]=\sum_{i=1}^n \|\nabla \tau (t_i)\|[t_i-t_{i-1}],$$ where $\nabla \tau$ is the gradient $\nabla \tau(t)=(\tau'_1(t), \ldots, \tau'_k(t))$.

As the partitions become finer and finer, these are Riemann sums which converge to the integral $\int_0^1 \|\nabla \tau(t)\|dt$, which is the exact value of the arc length.

Fix $(x_0,y_0)$, $(x_1,y_1)\in \mathbb{R}^2$ and a function $f:\mathbb{R}^2\to \mathbb{R}$. We want to travel over the surface, but above/below the straight line from $(x_0,y_0)$ to $(x_1,y_1)$.

Let $\tau_1(t)=(1-t)x_0+tx_1$, $\tau_2(t)=(1-t)y_0+ty_1$. Then $(\tau_1(t), \tau_2(t))$ traces out the line from $(x_0,y_0)$ to $(x_1,y_1)$ as $t$ goes from $0$ to $1$. For the $z$-coordinate, we need the height of the function: $$\tau_3(t) = f(\tau_1(t), \tau_2(t))= f((1-t)x_0+tx_1,(1-t)y_0+ty_1).$$

Note that $\tau'_1=x_1-x_0$, $\tau'_2=y_1-y_0$, and $$\tau'_3=\frac{\partial f}{\partial x}\cdot [x_1-x_0]+\frac{\partial f}{\partial y}[x_1-x_0].$$ This is a function of $t$, since $\frac{\partial f}{\partial x}$ is evaluated at the point $(x,y)=((1-t)x_0+tx_1,(1-t)y_0+ty_1)$.

The arc length is then $$\int_0^1 \sqrt{[x_1-x_0]^2+[y_1-y_0]^2+\biggl[\frac{\partial f}{\partial x}\cdot [x_1-x_0]+\frac{\partial f}{\partial y}[x_1-x_0]\biggr]^2}dt.$$