资源简介
x线段绘制,并且可以选中线段的起点或者终点,选中后可以拖动重新进行定位
代码片段和文件信息
#include “Graphbase.h“
#include
#include
double dist(PointEx p1 PointEx p2) {
return(sqrt((p1.x - p2.x)*(p1.x - p2.x) + (p1.y - p2.y)*(p1.y - p2.y)));
}
bool equalPoint(PointEx p1 PointEx p2) {
return ((fabs(p1.x - p2.x) }
double multiply(PointEx sp PointEx ep PointEx op) {
return((sp.x - op.x)*(ep.y - op.y) - (ep.x - op.x)*(sp.y - op.y));
}
double dotMultiply(PointEx p1 PointEx p2 PointEx p0) {
return ((p1.x - p0.x)*(p2.x - p0.x) + (p1.y - p0.y)*(p2.y - p0.y));
}
bool online(LineSegment l PointEx p) {
return((multiply(l.endPoint p l.startPoint) == 0)
&& (((p.x - l.startPoint.x)*(p.x - l.endPoint.x) <= 0) && ((p.y - l.startPoint.y)*(p.y - l.endPoint.y) <= 0)));
}
PointEx rotate(PointEx o double d PointEx p) {
PointEx tp;
p.x -= o.x;
p.y -= o.y;
tp.x = p.x*cos(d) - p.y*sin(d) + o.x;
tp.y = p.y*cos(d) + p.x*sin(d) + o.y;
return tp;
}
double angle(PointEx o PointEx s PointEx e) {
double cosfi fi norm;
double dsx = s.x - o.x;
double dsy = s.y - o.y;
double dex = e.x - o.x;
double dey = e.y - o.y;
cosfi = dsx*dex + dsy*dey;
norm = (dsx*dsx + dsy*dsy)*(dex*dex + dey*dey);
cosfi /= sqrt(norm);
if (cosfi >= 1.0) return 0;
if (cosfi <= -1.0) return -3.1415926;
fi = acos(cosfi);
if (dsx*dey - dsy*dex > 0) return fi; // 说明矢量os 在矢量 oe的顺时针方向
return -fi;
}
double relation(PointEx p LineSegment l) {
LineSegment tl;
tl.startPoint = l.startPoint;
tl.endPoint = p;
return dotMultiply(tl.endPoint l.endPoint l.startPoint) / (dist(l.startPoint l.endPoint)*dist(l.startPoint l.endPoint));
}
PointEx perpendicular(PointEx p LineSegment l) {
double r = relation(p l);
PointEx tp;
tp.x = l.startPoint.x + r*(l.endPoint.x - l.startPoint.x);
tp.y = l.startPoint.y + r*(l.endPoint.y - l.startPoint.y);
return tp;
}
double pToLinesegDist(PointEx p LineSegment l PointEx &np) {
double r = relation(p l);
if (r<0) {
np = l.startPoint;
return dist(p l.startPoint);
}
if (r>1) {
np = l.endPoint;
return dist(p l.endPoint);
}
np = perpendicular(p l);
return dist(p np);
}
double pToLDist(PointEx p LineSegment l) {
return fabs(multiply(p l.endPoint l.startPoint)) / dist(l.startPoint l.endPoint);
}
double pToPointSet(int vcount PointEx pointset[] PointEx p PointEx &q) {
int i;
double cd = double(INF) td;
LineSegment l;
PointEx tq cq;
for (i = 0; i < vcount - 1; i++) {
l.startPoint = pointset[i];
l.endPoint = pointset[i + 1];
td = pToLinesegDist(p l tq);
if (td < cd) {
cd = td;
cq = tq;
}
}
q = cq;
return cd;
}
bool circleInsidePolygon(int vcount PointEx center double radius PointEx polygon[]) {
PointEx q;
double d;
q.x = 0;
q.y = 0;
d = pToPointSet(vcount polygon center q);
if (d < radius || fabs(d - radius) < EP)
return true;
else
return false;
}
double cosine(LineSeg
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-09-16 11:58 Debug\
文件 1319 2018-09-16 11:58 Debug\MyGraphCal.Build.CppClean.log
文件 95 2018-09-16 11:58 Debug\MyGraphCal.log
目录 0 2018-09-16 12:25 Debug\MyGraphCal.tlog\
目录 0 2018-09-16 12:25 GeneratedFiles\
文件 38546 2018-09-15 16:49 Graph.h
文件 25856 2018-09-15 16:49 Graphba
文件 13243 2018-09-15 16:49 Graphba
文件 6086 2018-09-16 10:50 MyGraphCal.cpp
文件 1166 2018-09-16 10:38 MyGraphCal.h
文件 70 2018-09-15 16:50 MyGraphCal.qrc
文件 1055 2018-09-15 19:42 MyGraphCal.ui
文件 9185 2018-09-15 16:51 MyGraphCal.vcxproj
文件 2531 2018-09-15 16:51 MyGraphCal.vcxproj.filters
文件 751 2018-09-16 08:56 MyGraphCal.vcxproj.user
目录 0 2018-09-16 12:25 Resources\
文件 191 2018-09-15 16:50 main.cpp
- 上一篇:ImapiService.reg
- 下一篇:GraphTraversal.zip
相关资源
- QT5实现简单的TCP通信例程
- 变电站机器人监控系统界面
- MainWindow.rar
- qt QPainter 绘制跑马灯
- qt activemq mqtt 动态库
- Windows下基于Opencv+Qt的视频聊天客户端
- PyQt5:简单视频播放器
- Qt 使用sendemailapi实现邮件发送
- 关于QT多线程子线程使用信号和槽
- QT 窗口切换
- qt操作office文件的程序
- QTP10破解文件mgn-mqt82
- QT5日历源码
- Linux系统下基于Qt的局域网即时通信系
- QT TableView自定义委托
- 基于QT的简单视频播放器
- UR优傲机器人说明书
- tcpNum.zip
- QT项目code.rar
- qt做一个带有日历和钟表的界面
- 树莓派教程--Qt工程中使用DHT11传感器
- QT实现学生管理系统123783
- qt虚拟键盘26键和数字键
- 基于Qt界面显示的温湿度检测
- qt-opensource-linux-x64-5.7.0.run.txt
- 利用Qt实现的N皇后算法
- beatMouse.zip
- Qt 使用QPainter类在子控件上画图
- 基于Qt绘制的时间轴demo
- linux下QT游戏五子棋源代码
评论
共有 条评论