Plucker坐标与Plucker矩阵
最近学习Plucker坐标相关内容时,发现找到的资料比较少,而且有许多相互矛盾之处,这里开坑一一记录一下。
几何定义
假设 x , y \mathbf{x}, \mathbf{y} x,y是直线上的点,直线的Plucker坐标表示为 L : = ( l , m ) \mathbf{L}:=(\mathbf{l},\mathbf{m}) L:=(l,m),其中
- l = y − x \mathbf{l}=\mathbf{y}-\mathbf{x} l=y−x
- m = x × y \mathbf{m}=\mathbf{x}\times\mathbf{y} m=x×y
- ∥ m ∥ ∣ ∣ l ∣ ∣ \frac{\|\mathbf{m}\|}{||\mathbf{l}||} ∣∣l∣∣∥m∥为原点到直线距离
plucker坐标有6个分量,但是受到约束 m ⋅ l = 0 \mathbf{m}\cdot \mathbf{l}=0 m⋅l=0,以及齐次性,所以只有4个自由度。
注意,这一小节里的点都是3维的。下一小节用4维的齐次坐标了。
代数定义
假设 x = ( x 0 , x 1 , x 2 , x 3 ) T , y = ( y 0 , y 1 , y 2 , y 3 ) T \mathbf{x}=(x_0,x_1,x_2,x_3)^T, \mathbf{y}=(y_0,y_1,y_2,y_3)^T x=(x0,x1,x2,x3)T,y=(y0,y1,y2,y3)T是齐次坐标,其中 x 0 , y 0 x_0,y_0 x0,y0是额外引入的尺度项(我实在没找到这一项该怎么叫,既然它的作用是表征尺度大小,在本文中就姑且叫它尺度项吧)。定义 l i j = x i y j − x j y i l_{ij}=x_iy_j-x_jy_i lij=xiyj−xjyi,那么不难验证在尺度项 x 0 , y 0 x_0,y_0 x0,y0都是1时, l = ( l 01 , l 02 , l 03 ) T \mathbf{l}=(l_{01},l_{02},l_{03})^T l=(l01,l02,l03)T, m = ( l 23 , l 31 , l 12 ) T \mathbf{m}=(l_{23},l_{31},l_{12})^T m=(l23,l31,l12)T
于是Plucker坐标可以表示为
L
=
(
l
01
,
l
02
,
l
03
,
l
23
,
l
31
,
l
12
)
T
\mathbf{L}=(l_{01},l_{02},l_{03},l_{23},l_{31},l_{12})^T
L=(l01,l02,l03,l23,l31,l12)T
注意,在这里,我们把下标0当成了尺度项,这会让两种定义的坐标顺序是对应的。但是有些文章里坐标的顺序甚至下标的顺序(31还是13)都不一样。但这不是很重要,因为实际运算里还是用 l , m , l i j \mathbf{l},\mathbf{m},l_{ij} l,m,lij这种定义明确的符号比较多
Plucker坐标满足Grassmann–Plücker relations
l
01
l
23
+
l
02
l
13
+
l
03
l
12
=
0
l_{01}l_{23}+l_{02}l_{13}+l_{03}l_{12}=0
l01l23+l02l13+l03l12=0
这个其实就是几何定义里的约束方程,再考虑齐次性,Plucker坐标有4个自由度。
这里
L
L
L的定义也可以用外积来获得。
L
=
x
∧
y
=
(
x
0
e
0
+
x
1
e
1
+
x
2
e
2
+
x
3
e
3
)
∧
(
y
0
e
0
+
y
1
e
1
+
y
2
e
2
+
y
3
e
3
)
=
∑
i
,
j
(
x
i
y
j
−
x
j
y
i
)
e
i
∧
e
j
=
∑
i
,
j
l
i
j
e
i
∧
e
j
\begin{aligned} L&=\mathbf{x}\wedge\mathbf{y}\\ &=(x_0\mathbf{e}_0+x_1\mathbf{e}_1+x_2\mathbf{e}_2+x_3\mathbf{e}_3)\wedge(y_0\mathbf{e}_0+y_1\mathbf{e}_1+y_2\mathbf{e}_2+y_3\mathbf{e}_3)\\ &=\sum_{i,j}(x_iy_j-x_jy_i)\mathbf{e}_i\wedge\mathbf{e}_j\\ &=\sum_{i,j}l_{ij}\mathbf{e}_i\wedge\mathbf{e}_j \end{aligned}
L=x∧y=(x0e0+x1e1+x2e2+x3e3)∧(y0e0+y1e1+y2e2+y3e3)=i,j∑(xiyj−xjyi)ei∧ej=i,j∑lijei∧ej
或者取尺度项
x
=
y
=
1
x=y=1
x=y=1
L
=
(
e
0
+
x
ˉ
e
ˉ
)
∧
(
e
0
+
y
ˉ
e
ˉ
)
=
(
y
ˉ
−
x
ˉ
)
e
0
∧
e
ˉ
+
(
x
ˉ
×
y
ˉ
)
[
e
2
∧
e
3
,
e
3
∧
e
1
,
e
1
∧
e
2
]
\begin{aligned} L&=(\mathbf{e}_0+\bar{x}\mathbf{\bar{e}})\wedge(\mathbf{e}_0+\bar{y}\mathbf{\bar{e}})\\ &=(\bar{y}-\bar{x})\mathbf{e}_0\wedge\mathbf{\bar{e}}+(\bar{x}\times\bar{y})[\mathbf{e}_2\wedge\mathbf{e}_3, \mathbf{e}_3\wedge\mathbf{e}_1, \mathbf{e}_1\wedge\mathbf{e}_2] \end{aligned}
L=(e0+xˉeˉ)∧(e0+yˉeˉ)=(yˉ−xˉ)e0∧eˉ+(xˉ×yˉ)[e2∧e3,e3∧e1,e1∧e2]
分别对应了
l
\mathbf{l}
l和
m
\mathbf{m}
m。
题外话,其实外积用外积不仅可以获得直线,还可以获得平面,已知平面上不共线的三个点 x , y , z ∈ P 3 \mathbf{x},\mathbf{y},\mathbf{z}\in\mathbb{P}^3 x,y,z∈P3,平面坐标可以表示为 P = x ∧ y ∧ z ∈ Λ 3 ( R 4 ) P=\mathbf{x}\wedge\mathbf{y}\wedge\mathbf{z}\in\Lambda^3(\mathbb{R^4}) P=x∧y∧z∈Λ3(R4),反对称张量空间的维数为 C 4 3 = 4 C_4^3=4 C43=4,刚好和点的维数一样。
Plucker 矩阵
由
l
i
j
l_{ij}
lij构成的反对称矩阵称为Plucker矩阵, 记作
[
L
]
×
[\mathbf{L}]_\times
[L]×,那么
[
L
]
×
[\mathbf{L}]_\times
[L]×可以如下计算
L
=
[
L
]
×
=
x
y
T
−
y
x
T
=
(
0
l
01
l
02
l
03
−
l
01
0
l
12
l
13
−
l
02
−
l
12
0
l
23
−
l
03
−
l
13
−
l
23
0
)
L= [\mathbf{L}]_\times=\mathbf{x}\mathbf{y}^T-\mathbf{y}\mathbf{x}^T =\begin{pmatrix} 0 & l_{01} & l_{02} & l_{03} \\ -l_{01} & 0 & l_{12} & l_{13} \\ -l_{02} & -l_{12} & 0 & l_{23} \\ -l_{03} & -l_{13} & -l_{23} & 0 \end{pmatrix}
L=[L]×=xyT−yxT=
0−l01−l02−l03l010−l12−l13l02l120−l23l03l13l230
类似的,Plucker矩阵有6个变量,但是受到约束 d e t ( L ) = 0 det(L)=0 det(L)=0,以及齐次性,所以损失2个自由度
疑惑,这个Plucker矩阵按照定义来讲应该是我这么写,但是在维基百科和一些小论坛上看到的矩阵却是符号相反的。事实上按照我的写法,后面的公式(1),(2)和Result 8.3都会差一个负号。而且后面的公式在许多论文里都出现过,似乎又印证了维基是对的。所以接下来全部按照维基版本了。也就是
[
L
]
×
=
y
x
T
−
x
y
T
=
(
0
−
l
01
−
l
02
−
l
03
l
01
0
−
l
12
−
l
13
l
02
l
12
0
−
l
23
l
03
l
13
l
23
0
)
[\mathbf{L}]_\times=\mathbf{y}\mathbf{x}^T-\mathbf{x}\mathbf{y}^T =\begin{pmatrix} 0 & -l_{01} & -l_{02} & -l_{03} \\ l_{01} & 0 & -l_{12} & -l_{13} \\ l_{02} & l_{12} & 0 & -l_{23} \\ l_{03} & l_{13} & l_{23} & 0 \end{pmatrix}
[L]×=yxT−xyT=
0l01l02l03−l010l12l13−l02−l120l23−l03−l13−l230
注意,不同文章定义的齐次坐标里,尺度项位置不一样。有的是尺度项最前面 x = ( x , x ˉ ) \mathbf{x}=(x,\bar{x}) x=(x,xˉ),有的在最后面 x = ( x ˉ , x ) \mathbf{x}=(\bar{x},x) x=(xˉ,x)。这会导致 l , m \mathbf{l},\mathbf{m} l,m和 l i j l_{ij} lij的对应不一样,有2种情况。
对于
(
x
ˉ
,
x
)
(\bar{x},x)
(xˉ,x),也就是下标3是尺度项的情况,有
l
=
(
−
l
03
,
−
l
13
,
−
l
23
)
T
,
m
=
(
l
12
,
l
20
,
l
01
)
T
\mathbf{l}=(-l_{03},-l_{13},-l_{23})^T, \mathbf{m}=(l_{12},l_{20},l_{01})^T
l=(−l03,−l13,−l23)T,m=(l12,l20,l01)T。进而有
[
L
]
×
=
(
[
m
]
×
l
−
l
T
0
)
(1)
\begin{equation} [\mathbf{L}]_\times =\begin{pmatrix} [\mathbf{m}]_\times & \mathbf{l} \\ -\mathbf{l}^T & 0 \end{pmatrix} \end{equation}\tag{1}
[L]×=([m]×−lTl0)(1)
对于
(
x
,
x
ˉ
)
(x,\bar{x})
(x,xˉ),也就是下标0是尺度项的情况,有
l
=
(
l
01
,
l
02
,
l
03
)
T
,
m
=
(
l
23
,
l
31
,
l
12
)
T
\mathbf{l}=(l_{01},l_{02},l_{03})^T,\mathbf{m}=(l_{23},l_{31},l_{12})^T
l=(l01,l02,l03)T,m=(l23,l31,l12)T。进而有
[
L
]
×
=
(
0
−
l
l
T
[
m
]
×
)
(2)
\begin{equation} [\mathbf{L}]_\times =\begin{pmatrix} 0 & -\mathbf{l}\\ \mathbf{l}^T & [\mathbf{m}]_\times \end{pmatrix} \end{equation}\tag{2}
[L]×=(0lT−l[m]×)(2)
Plucker坐标下直线的变换
在这一节里我们使用 ( n , d ) (n,d) (n,d)和 ( x ˉ , x ) (\bar{x},x) (xˉ,x)的顺序。 ( n , d ) (n,d) (n,d)是normal和direction的意思,和之前刚好反过来,论文里经常这么写。从空间中三维直线到平面中二维直线的投影方程,写法有多种,这里一一记录。下面的上下标中,w是世界坐标系,c是相机坐标系,或者相机平面坐标系。
首先论文PL-VIO,知乎1,知乎2和博客中都用的是
[
n
c
d
c
]
=
[
R
c
w
[
t
c
w
]
×
R
c
w
0
R
c
w
]
[
n
w
d
w
]
⇒
n
c
=
R
c
w
n
w
+
[
t
c
w
]
×
R
c
w
d
w
(3)
\begin{aligned} \begin{bmatrix} n_c \\ d_c \end{bmatrix} &=\begin{bmatrix} R_{cw} & [t_{cw}]_\times R_{cw} \\ 0 & R_{cw} \end{bmatrix} \begin{bmatrix} n_w \\ d_w \end{bmatrix} \end{aligned}\\ \Rightarrow n_c =R_{cw}n_w+[t_{cw}]_\times R_{cw}d_w \tag{3}
[ncdc]=[Rcw0[tcw]×RcwRcw][nwdw]⇒nc=Rcwnw+[tcw]×Rcwdw(3)
它的证明可以在知乎1和博客里找到。这里其实是三维到三维的变换,下面会讲到,只考虑第一行就是二维直线了。
第二,在文献1中提到了直线变换方程
L
C
=
T
L
W
[
n
c
d
c
]
=
[
R
R
[
−
t
]
×
0
R
]
[
n
w
d
w
]
(4)
\mathbf{L}^C=T\mathbf{L}^W\\ \begin{bmatrix} n_c \\ d_c \end{bmatrix} =\begin{bmatrix} R & R[-\mathbf{t}]_\times \\ 0 & R \end{bmatrix} \begin{bmatrix} n_w \\ d_w \end{bmatrix} \tag{4}
LC=TLW[ncdc]=[R0R[−t]×R][nwdw](4)
文章说,只需要考虑法线向量 n \mathbf{n} n,不用考虑方向 d \mathbf{d} d。这是因为投影的直线在相机平面上,如果知道光心与直线成平面的法线,结合光心,就能确定光心与直线的平面,2个平面就可以确定直线。
补充,这几天翻了翻射影几何的书,其实是因为 P 2 \mathbb{P}^2 P2上的直线的表达式就是它的法向量。
所以只考虑第一行。
l
C
=
n
c
=
P
L
W
\mathbf{l}^C=\mathbf{n}_c=P\mathbf{L}^W
lC=nc=PLW
其中
l
C
\mathbf{l}^C
lC是二维直线的表达,对应于三维直线的法向量
n
n
n,
P
=
[
R
R
[
−
t
]
×
]
P=\begin{bmatrix} R & R[-\mathbf{t}]_\times \end{bmatrix}
P=[RR[−t]×]
是投影矩阵。最终有
l
C
=
n
c
=
R
(
n
+
[
−
t
]
×
d
)
\begin{equation} l^C=n_c=R(n+[-t]_\times d)\tag{5} \end{equation}
lC=nc=R(n+[−t]×d)(5)
最近阅读论文时看到ION的文献2也是这么写的。
但是仔细对比一下,就会发现,公式3和5展开之后不一样呀,最后一项一个是 [ − t ] × R d [-t]_\times Rd [−t]×Rd一个是 R [ − t ] × d R[-t]_\times d R[−t]×d。
这个问题困扰了我好几天,最后看了知乎1的推导后才恍然大悟,公式4和5中的t不是world2cam,而是cam2world呀!参考知乎1的推导
[
n
c
d
c
]
=
[
R
w
c
T
[
−
R
w
c
T
t
w
c
]
×
R
w
c
T
0
R
w
c
T
]
[
n
w
d
w
]
=
[
R
w
c
T
R
w
c
T
[
−
t
w
c
]
×
0
R
w
c
T
]
[
n
w
d
w
]
n
c
=
R
w
c
T
(
n
w
+
[
−
t
w
c
]
×
d
w
)
\begin{aligned} \begin{bmatrix} n_c \\ d_c \end{bmatrix} &=\begin{bmatrix} R_{wc}^T & [-R_{wc}^Tt_{wc}]_\times R_{wc}^T \\ 0 & R_{wc}^T \end{bmatrix} \begin{bmatrix} n_w \\ d_w \end{bmatrix}\\ &=\begin{bmatrix} R_{wc}^T & R_{wc}^T[-t_{wc}]_\times \\ 0 & R_{wc}^T \end{bmatrix} \begin{bmatrix} n_w \\ d_w \end{bmatrix} \end{aligned}\\ n_c =R_{wc}^T(n_w+[-t_{wc}]_\times d_w)
[ncdc]=[RwcT0[−RwcTtwc]×RwcTRwcT][nwdw]=[RwcT0RwcT[−twc]×RwcT][nwdw]nc=RwcT(nw+[−twc]×dw)
其中用到了后文的Result A4.3。这样就和公式3对应了。所以说如果遇到4,5这种形式的公式,里面的
R
R
R是
R
w
c
T
=
R
c
w
R_{wc}^T=R_{cw}
RwcT=Rcw,但是
t
t
t是
t
w
c
=
−
R
c
w
T
t
c
w
t_{wc}=-R_{cw}^Tt_{cw}
twc=−RcwTtcw。所以说,为什么要用c2w这么奇怪的表达啊。
文献2引用了Richard Hartley and Andrew Zisserman的多视角几何,使用了书中的又一种投影方程,注意这里的投影矩阵是 P = [ R c w , t c w ] P=[R_{cw},t_{cw}] P=[Rcw,tcw]了。
P198 的Result 8.3
Under the camera mapping P 3 × 4 P_{3\times4} P3×4, a line in a 3-space represented as a Plucker matrix L L L, is imaged as the line l \mathbf{l} l where
[ l ] × = P L P T [\mathbf{l}]_\times=PLP^T [l]×=PLPT
Proof: Suppose that a = P A \mathbf{a}=P\mathbf{A} a=PA, b = P B \mathbf{b}=P\mathbf{B} b=PB. The Plucker matrix for the line through A \mathbf{A} A and B \mathbf{B} B in 3-space is L = A B T − B A T L=\mathbf{A}\mathbf{B}^T-\mathbf{B}\mathbf{A}^T L=ABT−BAT. The matrix
M = P L P T = a b T − b a T = [ a × b ] × M=PLP^T=\mathbf{a}\mathbf{b}^T-\mathbf{b}\mathbf{a}^T=[\mathbf{a}\times\mathbf{b}]_\times M=PLPT=abT−baT=[a×b]×
Since the line through image points is given by l = a × b \mathbf{l}=\mathbf{a}\times\mathbf{b} l=a×b, the proof completes.
原书这个地方公式明显错了,应该是 a b T − b a T = − [ a × b ] × ab^T-ba^T=-[a\times b]_\times abT−baT=−[a×b]×。所以理论上最后的结果应该相差一个负号。
但是呢,最逆天的事情来了,前面定义Plucker矩阵L的时候,也多了一个负号,于是就出现了负负的正的现象。
你的矩阵比较松弛,但是呢,你的叉积又弥补了这一部分。如果按照公式推导,把负号去掉的话,就会有漏掉负号的轻狂
事实上,要是按照我上面的理解,定义 L = B A T − A B T L=\mathbf{B}\mathbf{A}^T-\mathbf{A}\mathbf{B}^T L=BAT−ABT就啥问题没有了。
下面这个结论也很重要,前面推公式的时候用到过。
582页的Result A4.3
For any vector t t t and non sigular matrix M, one has
[ t ] × M = M − T [ M − 1 t ] × [t]_\times M=M^{-T}[M^{-1}t]_\times [t]×M=M−T[M−1t]×
Proof: update later.Corollary: If M is a rotation matrix.
[ M t ] × = M [ t ] × M T [Mt]_\times=M[t]_\times M^T [Mt]×=M[t]×MT
对偶Plucker坐标与矩阵
懒得码字了,直接贴图片吧,源自博客
投影矩阵的另一种构造
这是MVG书中给出的结论,里面用到了一个恒等式,我翻到73页的3.14,却发现作者没给证明QAQ。真是留图不留种,(…)
这里的外积是两个4维向量外积,所以得到的维数是
C
4
2
=
6
C_4^2=6
C42=6维,对应于
P
=
[
R
,
R
[
−
t
]
×
]
P=[R,R[-\mathbf{t}]_\times]
P=[R,R[−t]×]
参考文献
[1] Camera Pose Estimation from Lines using Plücker Coordinates
[2] Development of a Navigation Solution for an Image Aided Automatic Landing System