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,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/zhishi/a/1701609212109810.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:判断两线段是否有交点并求出交点.doc
本文 PDF 下载地址:判断两线段是否有交点并求出交点.pdf
留言与评论(共有 0 条评论) |