0

I want to find point B on a surface in R3 with an algebraic expression

f(x,y) = x^3 + y^2,

given point A, so that point B is closest in Euclidean distance, and lies on the surface. [Please note that the surface on the plot is not x^3 + y^2, and it is for illustrative purposes only].

enter image description here

I am not a Matlab user, but I see that the function fmincon or fminsearch may be the way to go as suggested in this online accessible paper by J. BAEK, A. DEOPURKAR, AND K. REDFIELD (p. 24, Appendix). Alternatively I thought of parameterizing a sphere by its radius around the point A, and looking for its first tangent point to the surface, but that would spawn many more questions.

For fmincon it seems like the first order of things is to define a function to minimize, and that would be mathematically the Euclidean distance: So if point A is in a matrix, and corresponds to A(:,1) and B is defined as (b1,b2,b3), the formula to minimize would be

(A(1,1) - b1)^2 + (A(2,1) - b2)^2 + (A(3,1) - b3)^2

As in the first comment, since B has to be on the surface, the constraining condition would be

b3= b1^3 + b2^2.

I don't know how to formalize this in Matlab, and whether I would need for some initial point to start the process, or A is a valid starting point.

Antoni Parellada
  • 4,253
  • 6
  • 49
  • 114
  • you would also need to define some cosntrains for `bx` as it has to be in the surface. For any arbitrary `B`, the your equation will returns `A==B`. So you are missing something in your minimization formulation. – Ander Biguri Feb 14 '20 at 13:40
  • maybe this one can help https://math.stackexchange.com/questions/175624/finding-shortest-distance-between-a-point-and-a-surface – ThomasIsCoding Feb 14 '20 at 15:11

1 Answers1

0

As you wrote this problem can be solved with fminsearch. Some time ago I wrote a code solving your issue based on the NURB Toolbox for Matlab. I just simplified it a bit for your problem. In this case surf is a function handle to the surface function. If you have a better starting point then [0, 0], you may use it instead.

function Y = ProjectOnSurf(X,surf)
    %Computes the closest point to given point on a surface.
    f=@(lambda) norm(surf(lambda) - X)
    lambda=fminsearch(f,[0, 0]); %Find parameters for minimal distance
    Y=NurbEval(surf,lambda)'; %Solve function for parameters
end
Henrik
  • 39
  • 3