La = vertices[0].y - vertices[2].y;
							Lb = vertices[0].x - vertices[2].x;
							Lc = vertices[0].x*vertices[2].y - vertices[2].x*vertices[0].y;

							LLa = vertices[1].y - vertices[3].y;
							LLb = vertices[1].x - vertices[3].x;
							LLc = vertices[1].x*vertices[3].y - vertices[3].x*vertices[1].y;

							d = La*LLb - LLa*Lb;

							cout << "Cross .x=   " << (Lb*LLc - LLb*Lc) / d << endl;
							cout << "Cross.y=    " << (Lc*LLa - LLc*La) / d << endl;
							cross.x = abs((Lb*LLc - LLb*Lc) / d);
							cross.y = abs((Lc*LLa - LLc*La) / d);
							sprintf(mystr, "%lf, %lf", cross.x,cross.y);

参考了大牛的python 实现 

 

https://blog.csdn.net/jacke121/article/details/77098125

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐