简体   繁体   中英

how to create a plane from 4 corner points in matlab?

i'm trying to make a plane of 4 points that are in the corners of the plane. I used the Patch function to display this plane but I need the equation of this plane. Is there a way to do this in matlab? In fact, I want to calculate the distance of a set of points from this page. Is this also possible using the Patch function? 在此处输入图片说明

I am doubtful MATLAB's graphical objects have much mathematical capability built into them. I think the best way to reach your end goal is to do the arithmetic yourself.

A mathematical property that you should keep in mind is that only 3 points are required to uniquely define a plane. The 4th point on the plane is not necessary.

Quick summary of the method:

  • Given points x1, x2, x3 on a plane, we can define vectors v1 = x2-x1, v2 = x3-x1.
  • We then compute the normal vector n = v1 x v2 (cross product here).
  • We then normalise the normal vector n_hat = n / norm(n, 2)
  • For some arbitrary point x, its distance to the plane is just x.n_hat (dot product here).

Example code:

x = [35.625, 35.7 , 35.825, 35.75];
y = [56.25 , 56.25, 59.25 , 59.25];

% This example assumes vectors are column vectors
% Must be 3 element vectors to perform cross product
v1 = [x(2)-x(1)
      y(2)-y(1)
      0];
v2 = [x(3)-x(1)
      y(3)-y(1)
      0];

n = cross(v1, v2);
n_hat = n / norm(n, 2);

% the unused 4th point should have zero distance to the plane, so d4=0
p4 = [x(4); y(4); 0];
d4 = dot(n_hat, p4)

% the point d5=[0,0,2] is 2 units above the plane, so d5=0
p5 = [0; 0; 2];
d5 = dot(n_hat, p5)

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