2023年12月3日發(作者:兄弟節)

// : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "iostream.h"
struct point
{
double x;
double y;
};
point getinctpoint(point,point,point,point);
void main()
{
point pa,pb,pc,pd,pp;
cout<<"plea input the first line: "< cin>>pa.x>>pa.y>>pb.x>>pb.y; cout<<"n"<<"plea input the cond line: "< cin>>pc.x>>pc.y>>pd.x>>pd.y; pp=getinctpoint(pa,pb,pc,pd); if(pp.x==10000) cout<<"there exsits no point!!!"< el cout<<"the inctpoint is: " < } point getinctpoint(point a,point b,point c,point d) { double delta,r,u; point p; delta=(b.x-a.x)*(c.y-d.y)-(c.x-d.x)*(b.y-a.y); if(delta==0) { p.x=10000;p.y=10000; } el { r=((c.x-a.x)*(c.y-d.y)-(c.x-d.x)*(c.y-a.y))/delta; u=((b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y))/ delta; if((r>=0&&r<=1)&&(u>=0&&u<=1)) { p.x=a.x+r*(b.x-a.x); p.y=a.y+r*(b.y-a.y); } el { p.x=10000; p.y=10000; } } return p; } -

本文發布于:2023-12-03 21:13:31,感謝您對本站的認可!
本文鏈接:http://www.newhan.cn/zhishi/a/1701609212109810.html
版權聲明:本站內容均來自互聯網,僅供演示用,請勿用于商業和其他非法用途。如果侵犯了您的權益請與我們聯系,我們將在24小時內刪除。
本文word下載地址:判斷兩線段是否有交點并求出交點.doc
本文 PDF 下載地址:判斷兩線段是否有交點并求出交點.pdf
| 留言與評論(共有 0 條評論) |