当前位置:网站首页>Find the intersection of line segments
Find the intersection of line segments
2022-07-03 08:26:00 【T.D.C】
Find the intersection of line segments
- Copy the :https://www.geeksforgeeks.org/program-for-point-of-intersection-of-two-lines/
public struct Point{
public double x;
public double y;
public Point(double x, double y){
this.x = x;
this.y = y;
}
public static Point lineLineIntersection(Point A, Point B, Point C, Point D)
{
// Line AB represented as a1x + b1y = c1
double a1 = B.y - A.y;
double b1 = A.x - B.x;
double c1 = a1 * (A.x) + b1 * (A.y);
// Line CD represented as a2x + b2y = c2
double a2 = D.y - C.y;
double b2 = C.x - D.x;
double c2 = a2 * (C.x) + b2 * (C.y);
double determinant = a1 * b2 - a2 * b1;
if (determinant == 0)
{
// The lines are parallel. This is simplified
// by returning a pair of FLT_MAX
return new Point(double.MaxValue, double.MaxValue);
}
else
{
double x = (b2 * c1 - b1 * c2) / determinant;
double y = (a1 * c2 - a2 * c1) / determinant;
return new Point(x, y);
}
}
}
边栏推荐
- Simply start with the essence and principle of SOM neural network
- A tunnel to all ports of the server
- 简易入手《SOM神经网络》的本质与原理
- E: Unable to locate package ROS melody desktop full
- How to establish rectangular coordinate system in space
- [audio and video] ijkplayer error code
- About the problem that the editor and the white screen of the login interface cannot be found after the location of unityhub is changed
- 十六进制编码简介
- animation
- Redis data structure
猜你喜欢

Installation of PHP FPM software +openresty cache construction

Some understandings of 3dfiles

Base64编码简介

How to establish rectangular coordinate system in space

Visual Studio (VS) shortcut keys

Un système de gestion de centre commercial pour la conception de cours de technologie d'application de base de données

基于SSM的校园失物招领平台,源码,数据库脚本,项目导入运行视频教程,论文撰写教程
![P1596 [USACO10OCT]Lake Counting S](/img/a7/07a84c93ee476788d9443c0add808b.png)
P1596 [USACO10OCT]Lake Counting S

Oracle insert single quotation mark

Puhua PLM empowers the whole scene product lifecycle management and helps the enterprise digital transformation of the main line of products
随机推荐
Redis cluster series 4
Golang json格式和结构体相互转换
Solution détaillée de toutes les formules de fonction de transfert (fonction d'activation) du réseau neuronal MATLAB
Introduction to hexadecimal coding
Kwai 20200412 recruitment
Golang time format sorting
matlab神經網絡所有傳遞函數(激活函數)公式詳解
About Wireshark's unsuccessful installation of npcap
[cloud native] introduction and use of feign of microservices
100 GIS practical application cases (78) - Multi compliance database design and data warehousing
基于SSM的校园失物招领平台,源码,数据库脚本,项目导入运行视频教程,论文撰写教程
What is BFC?
Lua framwrok framework starts
Why can void * be a general pointer
C语言-入门-精华版-带你走进编程(一)
LinkList
go 解析身份证
Golang string segmentation, substitution and interception
Creation and content of mapnode -- osgearth rendering engine series (2)
Unity one click AssetBundle