MATLAB Answers

# How to find closest point in plane to another point? Matlab solution

10 views (last 30 days)
Sue Swenson on 2 May 2021
Answered: William Rose on 25 May 2021
If I have a plane
x+y+z=0
and want to find the closest point in this plane to
p=(1,1,1)
How could I do this in matlab? I understand how to do this mathematically, but can't figure the syntax
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Answers (1)

William Rose on 25 May 2021
A plane can be described by
This plane has normal vector .
Suppose is a given external point. Find the point in the plane which is closest to .
The equation which I derived to solve this problem is
We can implement the equation above in Matlab, recalling that prime denotes transpose in Matlab.
In your example, the plane is
x+y+z=0
and therefore and D=0. Also, in your example, the external point is .
The Matlab code to solve this is:
n=[1;1;1];
D=0;
p1=[1;1;1];
p0=p1-((n'*p1-D)/(n'*n))*n;
disp(p0)
0 0 0
Try it.
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!