下面的代码定义了平面的法线向量和半径以便可视化它。我的问题是关于d
和偏移。是d
平面方程中的 D吗Ax+By+Cz+D=0
(因为我必须给出 ad
而我找不到带有该代码的 D)?该代码将帮助我定义 3D 点是否位于平面的上方/下方、前方/后方、左侧/右侧。非常感谢任何有助于我理解这一点的反馈。
**function [fixture,n,min_radius] = planePointPoint(p1,p2,p3,q,d,varargin)**
% p1, p2 and p3 -3d points that define an oriented plane.
%q is the point that is tested against this plane
% p1+offset is the fixture point for the plane.
% d is the offset distance for the plane in the direction of n.
% optional argument offset is a 3-vector denoting an offset to be added to the fixture point during min_radius calculation
%
% function returns sequence of fixture points and unit normals along with
% minimum radii that make sense to visualize position of q in relation to the plane.
offset = [0;0;0];
if (nargin>6)
offset = varargin{1};
end
n = cross(p1 - p3,p2 - p3);%defines normal vector
n = n./repmat(sqrt(sum(n.^2)),3,1);%normalise normal vector
offset = repmat(offset,1,mot.nframes) - repmat(dot(n,repmat(offset,1,mot.nframes)),3,1).*n;
%points = p1 + n*d;
fixture = p1+offset + n*d;
dist_q = dot(n,q-fixture);
dist_p1 = dot(n,p1-fixture);
dist_p2 = dot(n,p2-fixture);
dist_p3 = dot(n,p3-fixture);
q_proj = q - repmat(dist_q,3,1).*n;
p1_proj = p1 - repmat(dist_p1,3,1).*n;
p2_proj = p2 - repmat(dist_p2,3,1).*n;
p3_proj = p3 - repmat(dist_p3,3,1).*n;
radius_q = sqrt(sum((fixture-q_proj).^2));
radius_p1 = sqrt(sum((fixture-p1_proj).^2));
radius_p2 = sqrt(sum((fixture-p2_proj).^2));
radius_p3 = sqrt(sum((fixture-p3_proj).^2));
min_radius = max([radius_q; radius_p1; radius_p2; radius_p3]);