当前位置:网站首页>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);
}
}
}
边栏推荐
- Golang 中string和int类型相互转换
- Transmit pictures with Base64 encoding
- 十六进制编码简介
- MySQL containerization (1) docker installation MySQL
- Image processing 8-cnn image classification
- Golang中删除字符串的最后一个字符
- Osgearth north arrow display
- A tunnel to all ports of the server
- Conversion between golang JSON format and structure
- Get to know unity2 for the first time
猜你喜欢

Simply start with the essence and principle of SOM neural network

详解sizeof、strlen、指针和数组等组合题

了解小程序的笔记 2022/7/3

Display terrain database on osgearth ball

Easy touch plug-in

Transplantation of freetype Library

简易入手《SOM神经网络》的本质与原理

Image processing 8-cnn image classification

MySQL 8

Dealing with duplicate data in Excel with xlwings
随机推荐
swagger文档配置
Golang time format sorting
Shader foundation 01
E: Unable to locate package ROS melody desktop full
Redis cluster series 4
Introduction to hexadecimal coding
Solution détaillée de toutes les formules de fonction de transfert (fonction d'activation) du réseau neuronal MATLAB
C#课程设计之学生教务管理系统
jupyter远程服务器配置以及服务器开机自启
MySQL 8
Advanced OSG collision detection
Dotween plug-in
Osgearth target selection
Clion toolchains are not configured configure disable profile problem solving
796 · 开锁
MXone Pro自适应2.0影视模板西瓜视频主题苹果cmsV10模板
What is BFC?
796 · unlock
Cesium service deployment, and import and display local 3dfiles data
Creation of osgearth earth files to the earth ------ osgearth rendering engine series (1)