Qt中求两线段交点

QPointF MapEditor::getIntersectPos(QPointF posA, QPointF posB, QPointF posC, QPointF posD)//返回AB与CD交点,无交点返回(0,0)
{
    QLineF line1(posA, posB);
    QLineF line2(posC, posD);
    QPointF interPos(0,0);
    QLineF::IntersectType type = line1.intersect(line2, &interPos);
    if (type != QLineF::BoundedIntersection)
        interPos = QPointF(0, 0);
    return interPos;
}
时间: 2024-07-30 00:40:41

Qt中求两线段交点的相关文章

matlab练习程序(求n线段交点)

很简单的算法,这里是把每对线段都进行比较了. 还有一种似乎先通过x和y排序再进行交点判断的,不过那种方法我还没看太明白. 这里的方法如下: 1.根据线段的端点求两条直线的交点. 2.判断直线的交点是否在两条线段上. 结果如下: matlab代码如下: clear all;close all;clc; n=20; p=rand(n,4); %(x1,y1,x2,y2)线段两端点 for i=1:n pbar=p(i,:); pbar=reshape(pbar,[2,2]); line(pbar(1

Fermat Point in Quadrangle(hdu 3694 求两直线交点

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3694 画几个图应该就可以知道凸四边形就是对角线交点 凹四边形就是凹进去的那个点 so 只要枚举四个点以及对角线交点 找个minn就可以 求两直线交点模板: double cross(double x1,double y1,double x2,double y2) { return x1*y2-x2*y1; } bool getcross(double x1,double y1,double x2,d

Python中求两个list列表中共同元素??

1 # 求两个list中的共同元素 2 def commonElement(): 3 a=[1,2,3,5,6]; 4 b=[1,2,5]; 5 commonEle=[val for val in a if val in b]; 6 commonNum=len(commonEle); 7 return commonEle,commonNum; 运行结果: import randMatrix;为自己建立的模块 1 >>> import randMatrix; 2 >>>

2D空间中求两圆的交点

出处:https://stackoverflow.com/questions/19916880/sphere-sphere-intersection-c-3d-coordinates-of-collision-points 修改(加入包含和不相交情况的判断): using System.Collections; using System.Collections.Generic; using UnityEngine; public class CircleIntersect : MonoBehav

Gym - 101915B Ali and Wi-Fi 计算几何 求两圆交点

题面 题意:给你n个圆,每个圆有一个权值,你可以选择一个点,可以获得覆盖这个点的圆中,权值最大的m个的权值,问最多权值是多少 题解:好像是叙利亚的题....我们画画图就知道,我们要找的就是圆与圆交的那部分里面的点,我们再仔细看看, 2个圆的交点一定在啊! 别急啊,两个圆包含了,都是交点,取哪呢?当然小圆圆心就够了啊(圆又不多,写的时候直接把所有的圆心都丢进去了) 然后枚举判断每个点有没有被在m个圆中就行了,这里维护最大的m个,用个堆就好了 1 #include<bits/stdc++.h> 2

Qt分析:Qt中的两种定时器(可是QObject为什么要提高定时器呢,没必要啊。。。)

Qt有两种定时器,一种是QObject类的定时器,另一种是QTimer类的定时器. (1)QObject类的定时器 QObject类提供了一个基本的定时器,通过函数startTimer()来启动,通过killTimer()来结束,通过QTimerEvent来处理定时器事件. int startTimer(int interval, Qt::TimerType timerType = Qt::CoarseTimer); void killTimer(int id); void QObject::t

java中求两个数组(集合)的交集,并集,差集

对于两个数组 arr1=[1,3,4,5,8,9] arr2=[2,3,7,8,9] 求出交集与并集 test.java 1 import java.util.ArrayList; 2 import java.util.Collections; 3 4 5 public class test1 { 6 public static void main(String[] args) { 7 ArrayList<Integer> tmplist=new ArrayList<Integer>

ENVI中求两幅影像的相关系数

第一步:要求相关系数,必须先将两个或者波段合成(Layer Stacking),然后在工具箱中打开Compute Statistics,选择合成后的数据,再选择参与的波段数,如下图所示:  第二步:勾选Covariance复选框    第三步:查看相关系数

POJ2826 An Easy Problem?!(线段交点,三角形面积)

题目链接: http://poj.org/problem?id=2826 题目描述: An Easy Problem?! Description It's raining outside. Farmer Johnson's bull Ben wants some rain to water his flowers. Ben nails two wooden boards on the wall of his barn. Shown in the pictures below, the two b