简体   繁体   English

如何在 3D 表面上找到最接近该表面外点的点?

[英]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我想用代数表达式在 R3 的表面上找到点 B

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

given point A, so that point B is closest in Euclidean distance, and lies on the surface.给定点 A,所以点 B 在欧几里德距离上最近,并且位于表面上。 [Please note that the surface on the plot is not x^3 + y^2, and it is for illustrative purposes only]. [请注意,图中的曲面不是 x^3 + y^2,仅用于说明目的]。

在此处输入图片说明

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).我不是 Matlab 用户,但我看到函数fminconfminsearch可能是 J. BAEK、A. DEOPURKAR 和 K. REDFIELD(第 24 页,附录)在这篇可访问的在线论文中所建议的方法。 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.或者,我想通过围绕 A 点的半径来参数化一个球体,并寻找它与表面的第一个切点,但这会产生更多的问题。

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对于 fmincon 似乎第一件事是定义一个函数来最小化,这在数学上是欧几里得距离:所以如果点 A 在矩阵中,并且对应于 A(:,1) 并且 B 被定义为(b1,b2,b3),最小化公式为

(A(1,1) - b1)^2 + (A(2,1) - b2)^2 + (A(3,1) - b3)^2 (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与第一条评论一样,由于 B 必须在表面上,因此约束条件将是

b3= b1^3 + b2^2. 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.我不知道如何在 Matlab 中将其形式化,也不知道我是否需要某个初始点来启动该过程,或者 A 是一个有效的起点。

As you wrote this problem can be solved with fminsearch.正如你所写,这个问题可以用 fminsearch 解决。 Some time ago I wrote a code solving your issue based on the NURB Toolbox for Matlab.前段时间我写了一个代码来解决你的问题,基于 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.在这种情况下, surf 是表面函数的函数句柄。 If you have a better starting point then [0, 0], you may use it instead.如果你有一个比 [0, 0] 更好的起点,你可以改用它。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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