n条直线交点拟合求交点

  1. 直线方程的公式有以下几种形式

    斜截式:y=kx+b

    截距式:x/a+y/b=1

    两点式:(x-x1)/(x2-x1)=(y-y1)/(y2-y1)

    一般式:ax+by+c=0(可以表达任意直线)

    只要知道两点坐标,代入任何一种公式,都可以求出直线的方程

  2. 一般式方程在计算机领域的重要性

    常用的直线方程有一般式 点斜式 截距式 斜截式 两点式等等。除了一般式方程,它们要么不能支持所有情况下的直线(比如跟坐标轴垂直或者平行),要么不能支持所有情况下的点(比如x坐标相等,或者y坐标相等)。所以一般式方程在用计算机处理二维图形数据时特别有用。

    已知直线上两点求直线的一般式方程

    已知直线上的两点P1(X1,Y1) P2(X2,Y2), P1 P2两点不重合。则直线的一般式方程AX+BY+C=0中,A B C分别等于:

    A = Y2 - Y1

    B = X1 - X2

    C = X2*Y1 - X1*Y2

    参考:http://blog.csdn.net/madbunny/article/details/43955883

    3.求两直线交点一般方程法:

    直线的一般方程为F(x) = ax + by + c = 0。既然我们已经知道直线的两个点,假设为(x0,y0), (x1, y1),那么可以得到a = y0 – y1, b = x1 – x0, c = x0y1 – x1y0。

    因此我们可以将两条直线分别表示为

    F0(x) = a0*x + b0*y + c0 = 0, F1(x) = a1*x + b1*y + c1 = 0

    那么两条直线的交点应该满足

    a0*x + b0*y +c0 = a1*x + b1*y + c1

    由此可推出

    x = (b0*c1 – b1*c0)/D

    y = (a1*c0 – a0*c1)/D

    D = a0*b1 – a1*b0, (D为0时,表示两直线平行)

    二者实际上就是连立方程组

    F0(x) = a0*x + b0*y + c0 = 0,

    F1(x) = a1*x + b1*y + c1 = 0

    参考:http://blog.csdn.net/abcjennifer/article/details/7584628

    设两直线的交点为:(x,y)

    [a0a1b0b1c0c1]???xy1???=0(1)

    若有n条直线拟合求交点,则同时联立(1)式中2n个方程,即:

    ?????????????a10a11a20a21...an0an1b10b11b20b21...bn0bn1c10c11c20c21...cn0cn1????????????????xy1???=0(2)

时间: 2024-07-30 00:40:35

n条直线交点拟合求交点的相关文章

Intersecting Lines--POJ1269(判断两条直线的关系 && 求两条直线的交点)

http://poj.org/problem?id=1269 我今天才知道原来标准的浮点输出用%.2f   并不是%.2lf  所以wa了好几次 题目大意:   就给你两个线段 然后求这两个线段所在的直线的关系  有共线  平行  和相交 #include<stdio.h> #include<string.h> #include<stdlib.h> #include<ctype.h> #include<math.h> #define N 200

判断两条直线是否相交点

#pragma mark ------------ 判断两条直线是否相交 + (BOOL)checkLineIntersection:(CGPoint)p1 p2:(CGPoint)p2 p3:(CGPoint)p3 p4:(CGPoint)p4 {     CGFloat denominator = (p4.y - p3.y) * (p2.x - p1.x) - (p4.x - p3.x) * (p2.y - p1.y);          if (denominator == 0.0f) {

求两条直线(线段)的交点

转自: http://blog.csdn.net/dgq8211/article/details/7952825 如图,如何求得直线 AB 与直线 CD 的交点P? 以上内容摘自<算法艺术与信息学竞赛>. 思路就是利用叉积求得点P分线段DC的比,然后利用高中学习的定比分点坐标公式求得分点P的坐标. 看不懂的可以去复习下 定比分点 的知识. 1 #include <math.h> 2 #include <stdio.h> 3 #include <string.h&g

poj1039——计算几何 求直线与线段交点,判断两条直线是否相交

poj1039——计算几何  求直线与线段交点,判断两条直线是否相交 Pipe Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9439   Accepted: 2854 Description The GX Light Pipeline Company started to prepare bent pipes for the new transgalactic light pipeline. During the de

求平面内两条直线的交点

The  and  coordinates of the point of intersection of two non-vertical lines can easily be found using the following substitutions and rearrangements. Suppose that two lines have the equations  and  where  and  are the slopes (gradients) of the lines

求两条直线的交点

CvPoint GetTwoLineCrossPoint(const int& x1, const int& y1, const int& x2, const int& y2, const int& x3, const int& y3, const int& x4, const int& y4) { //第一条直线的参数 double a0 = y1 - y2; double b0 = x2 - x1; double c0 = x1 * y2

求直线与线段的交点

1,求点到直线的带符号距离: float getSignedDistance(点P,直线AB) //求点P到直线AB的带符号距离(当P在AB左侧时距离为正,右侧时为负) { dir=直线AB的方向向量 根据dir求出直线AB的左手法线向量leftNormal = (-dir.y,dir.x).normalized 线段AP在leftNormal上的投影即为P到直线AB的带符号距离: signedDistance=dot(AP,leftNormal); return signedDistance;

两边点连直线求交点总数 树状数组或线段树 poj 3067 Japan

http://poj.org/problem?id=3067 Japan Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 23602   Accepted: 6369 Description Japan plans to welcome the ACM ICPC World Finals and a lot of roads must be built for the venue. Japan is tall island

计算两条直线的交点(C#)

从其他地方看到的源码是有问题的. /// <summary> /// 计算两条直线的交点 /// </summary> /// <param name="lineFirstStar">L1的点1坐标</param> /// <param name="lineFirstEnd">L1的点2坐标</param> /// <param name="lineSecondStar"