【问题标题】:Projection matrix to project a point in a plane投影矩阵在平面上投影一个点
【发布时间】:2014-08-01 13:45:42
【问题描述】:

如何确定 4x4 S 矩阵,使 P 在 XZ (Y=0) 平面上投影到 Q 中?

Q = S P

【问题讨论】:

  • 这是一个未定问题:您可以想象相机围绕从 P 到 Q 的射线旋转。您需要添加约束。

标签: matrix projection projection-matrix


【解决方案1】:

射线的坐标 r(t) = L + t * (P-L)。那是组件形式:

r_x = L_x + t*(P_x-L_x)
r_y = L_y + t*(P_y-L_y)
r_z = L_z + t*(P_z-L_z)

现在你需要找到 Q = r(t) 使得r_y = 0。这是在t = -L_y/(P_y-L_y)

时完成的
Q_x = L_x - L_y/(P_y-L_y)*(P_x-L_x)
Q_y = 0
Q_z = L_z - L_y/(P_y-L_y)*(P_z-L_z)

一般来说,投影平面由单位法向量n=(n_x,n_y,n_z)和平面到原点的距离d定义。如果 r(tn 则点 r(t) 位于平面上strong>=d 其中·是向量点积。

Q点的解一般是

t = (d - n·L)/(n ·(P-L))

Q = L + t *( P-L )

在伪 C 样式代码中,上面是:

// L : Light Source 
// P : Point to be projected
// n : Plane _unit_ normal vector
// d : Distance of plane to the origin
// returns: The point Q along the ray that intersects the plane.
Vector3 HitPlaneWithRay(Vector3 L, Vector3 P, Vector3 n, double d)
{
    double t = (d-Dot(L,n))/Dot(P-L,n);
    return L + t*(P-L);
}
// Intersect ray with floor (Normal=[0,1,0], Distance=0)
Vector3 HitFloorWithRay(Vector3 L, Vector3 P)
{
    return HitPlaneWithRay(L, P, Vector3.J, 0);
}

【讨论】:

  • 虽然这是正确的,但问题是如何找到执行此投影的 4x4 矩阵。
【解决方案2】:

我将给出从点L到平面E的中心投影的一般解决方案(假设L不包含在E)。

为方便起见,我将使用 Octave/MATLAB 表示法。

L在齐次坐标中给出

L=[lx ly lz 1]'

E以Hessian范式给出(也是齐次坐标)

E=[nx, ny, ,nz, d]'

其中 [nx, ny, nz] 是平面的法线,d 是它到原点的有符号距离。

然后是矩阵S,它将任意点P(也是齐次坐标)通过投影中心投影到平面E >L

S=eye(4)*(L'*E)-L*E'

中心投影是

Q=S*P

作为 Octave/MATLAB 函数

% A matrix S describing central projection to a plane E
% L a point in homogeneous coordinates of projective 3-space
% E a plane in homogeneous coordinates of projective 3-space
% Requirement: scalar product of L and E is non-zero (i.e. L is not contained in E)
function S = central_projection_to_plane(L, E)
    S = [
     + L(2)*E(2) + L(3)*E(3) + L(4)*E(4), - L(1)*E(2)                         , - L(1)*E(3)                         , - L(1)*E(4)                        ;
     - L(2)*E(1)                        , + L(1)*E(1) + L(3)*E(3) + L(4)*E(4) , - L(2)*E(3)                         , - L(2)*E(4)                        ;
     - L(3)*E(1)                        , - L(3)*E(2)                         , + L(1)*E(1) + L(4)*E(4) + L(2)*E(2) , - L(3)*E(4)                        ;
     - L(4)*E(1)                        , - L(4)*E(2)                         , - L(4)*E(3)                         , + L(1)*E(1) + L(2)*E(2) + L(3)*E(3)
];
end % function

P.S.:要得出这个结论,请注意,通过 LP 的线可以写成 4x4 Plücker 矩阵

Rx=L*P'-P*L'.

线Rx与平面E的交点很简单

Q=Rx*E
 =(L*P'-P*L')*E
 =(eye(4)*(L'*E)-L*E')*P
 =S*P

另请参阅:https://en.wikipedia.org/wiki/Plücker_matrix

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-02-22
    • 2012-03-27
    • 1970-01-01
    • 1970-01-01
    • 2015-04-11
    • 2015-11-01
    • 2018-10-29
    • 2019-03-05
    相关资源
    最近更新 更多