$$ \newcommand{\seq}[2]{{#1}_{1},{#1}_{2},\cdots,{#1}_{#2}} \newcommand{\num}[1]{1,2,\cdots,#1} \newcommand{\stra}[2]{\begin{bmatrix}#1 \\ #2\end{bmatrix}} \newcommand{\strb}[2]{\begin{Bmatrix}#1 \\ #2\end{Bmatrix}} \newcommand{\dw}[1]{\underline{#1}} \newcommand{\up}[1]{\overline{#1}} $$

计算几何

点积、叉积

\(u×v<0\)\(u\)\(v\) 的逆时针方向

判断线段相交,求交点

首先判断两条线段是否相交

图中,设两线段交点为 \(E\)
\(\because \frac{|CE|}{|DE|}=\frac{△ACD在CD边上的高}{△BCD在CD边上的高}\;\;=\frac{S_{△ACD}}{S_{△BCD}}=\frac{CD×CA}{CB×CD}=\frac{(x_D-x_C)(y_A-y_C)-(x_A-x_C)(y_D-y_C)}{(x_B-x_C)(y_D-y_C)-(x_D-x_C)(y_B-y_C)}=k\)
\(\therefore E=(\frac{k*x_B+x_A}{k+1},\frac{k*y_B+y_A}{k+1}),CE=\frac{k}{k+1}CD\)

point intersect(point P,Vector v,point Q,Vector w){
        point ret;
        Vector u=P-Q;
        if(sgn(cross(v,w))==0)return false;
        double t=cross(w,u)/cross(v,w);
        ret=P+v*t;
        return ret;
}

点的旋转、坐标轴的旋转

点的旋转

\(s=x\cos b-y\sin b\)
\(t=x\sin b+y\cos b\)

坐标轴的旋转

\(s=x\cos \theta+y\sin \theta\)
\(t=y\cos \theta-x\sin \theta\)


参考资料:
https://blog.csdn.net/roslei/article/details/72956020
posted @ 2019-02-15 19:27  chc_1234567890  阅读(176)  评论(0编辑  收藏  举报