简体   繁体   中英

How can I find the point on a 3D surface closest to a point outside that surface?

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].

在此处输入图片说明

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM