下面的代碼定義了法向量和平面的半徑以便可視化它。我的問題是關於d
和偏移量。是d
從平面方程D Ax+By+Cz+D=0
(因爲我必須給d
,我沒有找到一個與該代碼)?該代碼將幫助我定義3D點是在飛機的前/後,左側還是右側。 任何反饋,這將有助於我理解這一點,非常感謝。用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]);
謝謝您的回覆。我也相信這一點。我無法理解爲什麼要從用戶那裏詢問d。基本上,代碼是爲飛機設置動畫,所以我認爲它可以找到最大半徑以便創建一個光盤來爲飛機設置動畫。我使用相同的代碼來定義相對於飛機的虛擬3d點。 –
我發現如果法線向量被歸一化,D是原點的帶符號距離。因爲我使用骨架運動的代碼,可以將用戶定義的代碼中的閾值作爲閾值?例如d = 2 *骨架中肱骨的長度。此外代碼中的固定裝置,意味着我將原點轉移到了飛機的一個點上?再次感謝鮑里斯的回答 –
再次@ pap-00。恐怕我無法幫你解決這個問題。沒有更多的上下文,我無法猜測變量的含義,無論如何,即使我掌握了這些信息,也需要花費大量的時間,我無法承受:-)你必須弄清楚現在你自己。如果您仍然無法理解它,請聯繫圖書館的其他用戶或圖書館的作者,只有他們會有答案。 – Boris