一些东西
FourteenObsidian
·
·
个人记录
不熟悉的小东西
位运算
-
a+b=(a\ \mathrm{or}\ b)+(a\ \mathrm{and}\ b)
-
a\ \mathrm{xor}\ b=(a\ \mathrm{or}\ b)-(a\ \mathrm{and}\ b)
-
a+b=(a\ \mathrm{xor}\ b)+2(a\ \mathrm{and}\ b)
向量转角
设原来的是 (x,y),令其长度 l=\sqrt{x^2+y^2}, 角度
\theta = \mathrm{atan}(\frac{y}{x})
即 x=l\cos\theta,y=l\sin\theta。
设逆时针转的角度为 \alpha,则结果为
(l\cos(\theta+\alpha), l\sin(\theta+\alpha))\\
=(l(\cos\theta\cdot\cos\alpha-\sin\theta\cdot\sin\alpha), l(\sin\theta\cdot\cos\alpha+\cos\theta\cdot\sin\alpha))\\
=(x\cos\alpha-y\sin\alpha, y\cos\alpha+x\sin\alpha)
组合数
上指标求和
\sum_{i=0}^n\binom{i}{m}=\binom{n+1}{m+1}
对角线求和
\sum_{i=0}^n\binom{i+m}{i}=\binom{n+m+1}{n}