[NetTopologySuite](1)线面相交
用DotSpatial.Topology进行的测试,即使用NetTopologySuite类库进行测试:
Polygon inputGeometry = null;
LineString analysisGeoemtry = null;
private void button1_Click(object sender, EventArgs e)
{
var coords = new Coordinate[];
// Shell Coordinates
var coordscheck = new Coordinate[];
double[] Xs = new double[] { , , , , , , , , , , , , , };
double[] Ys = new double[] { , , , , , , , };
for (var i = ; i < Xs.Length / ; i++)
{
var x = Xs[i * ];
var y = Xs[i * + ];
coords[i] = new Coordinate(x, y);
coordscheck[i] = new Coordinate(x, y);
}
//coordscheck[19] = new Coordinate(coords[0].X, coords[0].Y);
//coords[19] = new Coordinate(coords[0].X, coords[0].Y);
// Shell Rings
var ring = new LinearRing(coords);
var gf = new GeometryFactory();
var ringCheck = gf.CreateLinearRing(coordscheck);
// Hole Coordinates
var coordsholecheck = new Coordinate[];
var coordshole = new Coordinate[];
for (var i = ; i < Ys.Length / ; i++)
{
var x = Ys[i * ];
var y = Ys[i * + ];
coordshole[i] = new Coordinate(x, y);
coordsholecheck[i] = new Coordinate(x, y);
}
// Hole LinearRing Arrays
var hole = new LinearRing(coordshole);
var holes = new ILinearRing[];
var holeCheck = gf.CreateLinearRing(coordsholecheck);
var holescheck = new ILinearRing[];
holes[] = hole;
holescheck[] = holeCheck;
Polygon pg = new Polygon(ring, holes);//
var polygonCheck = gf.CreatePolygon(ringCheck, holescheck);
var areaCheck = polygonCheck.Area;
var area = pg.Area;
//
inputGeometry = pg; double[] Lines = new double[] { , , , };
var coords1 = new Coordinate[];
var rnd1 = new Random();
var coordscheck1 = new Coordinate[];
for (var i = ; i < Lines.Length / ; i++)
{
var x = Lines[i * ];
var y = Lines[i * + ];
coords1[i] = new Coordinate(x, y);
coordscheck1[i] = new Coordinate(x, y);
} var gf1 = new GeometryFactory();
var lscheck = gf1.CreateLineString(coordscheck1);
LineString ls = new LineString(coords1);
analysisGeoemtry = ls;
intersectionOutput = analysisGeoemtry.Intersection(inputGeometry);
this.Invalidate();
}
IGeometry intersectionOutput = null;
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics gc = this.CreateGraphics();
if (inputGeometry != null)
{
GraphicsHelper.DrawPolygon(gc, inputGeometry, new SolidBrush(Color.Red), new Pen(new SolidBrush(Color.LightYellow)), false);
}
if (analysisGeoemtry != null)
{
GraphicsHelper.DrawLineString(gc, analysisGeoemtry, new Pen(new SolidBrush(Color.Blue)));
}
if (intersectionOutput != null)
{
if (intersectionOutput is LineString)
{
LineString lsr = intersectionOutput as LineString;
Pen mp = new Pen(new SolidBrush(Color.Yellow));
mp.Width = ;
GraphicsHelper.DrawLineString(gc, lsr, mp);
}
if (intersectionOutput is MultiLineString)
{
MultiLineString mlsr = intersectionOutput as MultiLineString;
for (int i = ; i < mlsr.NumGeometries; i++)
{
if (mlsr.Geometries[i] is LineString)
{
LineString lsr = mlsr.Geometries[i] as LineString;
Pen mp = new Pen(new SolidBrush(Color.Yellow));
mp.Width = ;
GraphicsHelper.DrawLineString(gc, lsr, mp);
}
}
}
}
gc.Dispose();
}
[NetTopologySuite](1)线面相交的更多相关文章
- Axiom3D:Ogre射线与点,线,面相交,鼠标操作3维空间.
在第一篇网络分解成点,线,面.第二篇分别点以球形,线以圆柱,面分别以MergerBatch整合批次显示.因为整合批次显示后,相应的点,线,面不能以Ogre本身的射线来选取,因为整合后,以点举例,多个点 ...
- 7.3---直线是否相交(CC150)
注意:就算斜率相等,但是,如果截距也相等,那么是属于相交,所以要特殊判断. public class CrossLine { public boolean checkCrossLine(double ...
- POJ 3304 Segments(线的相交判断)
Description Given n segments in the two dimensional space, write a program, which determines if ther ...
- visio直线交叉相交跨线修改
在使用visio画流程图时,经常会遇到两条直线相交.下面讲如何修改使得相交点变成我们想要的方式. 可以设置如下: (1) 全局直线相交,设置跨线标志. (2) 对每条线进行相交跨线设置. (一) ...
- 计算几何基础——矢量和叉积 && 叉积、线段相交判断、凸包(转载)
转载自 http://blog.csdn.net/william001zs/article/details/6213485 矢量 如果一条线段的端点是有次序之分的话,那么这种线段就称为 有向线段,如果 ...
- ArcMAp对线要素进行平滑处(打断)
一:工具简单介绍 -- ArcMAp10.1的高级编辑工具中提供了对线/面要素进行概括/平滑处理的工具. 概括工具.平滑工具分别例如以下:(首先得开启编辑状态 --- 才干够对要素的属性进行更改).选 ...
- iOS 2D绘图 (Quartz2D)之路径(点,直线,虚线,曲线,圆弧,椭圆,矩形)
博客原地址:http://blog.csdn.net/hello_hwc?viewmode=list 让我们继续跟着大神的脚步前进吧.这一次 我们学习一些Quartz 2D 最基本的一些用法. 前言: ...
- 探索性思维——How to Solve It
我觉得这篇文章和什么都能扯上点关系,比如编程. 很多人已经讨论过数学与编程的关系了,这里不想过多探讨,只是简单提一下:有些人把数学贬低地一文不值,认为做一般的应用软件用不到数学:而有些人则把数学拔高到 ...
- Andrew Ng机器学习公开课笔记 -- 支持向量机
网易公开课,第6,7,8课 notes,http://cs229.stanford.edu/notes/cs229-notes3.pdf SVM-支持向量机算法概述, 这篇讲的挺好,可以参考 先继 ...
随机推荐
- ZZULIOJ 1726 迷宫(BFS+小坑)
1726: 迷宫 Time Limit: 1 Sec Memory Limit: 128 MB Submit: 394 Solved: 64 SubmitStatusWeb Board Descr ...
- JavaScript系列:函数调用方式
有关JS的问题,持续更新.. 一,函数调用的4种方式 1,函数调用模式 //下面这种模式叫 “函数调用模式”:窗后window来调用 //函数调用四种方式的基础 //这tm不就是作用域this的问题吗 ...
- 利用SpannableString设置文本
private void setTips(){ String big = "大字深色"; String small = "小字淡色"; Spannable ti ...
- 自定义UserProvider,更改验证方法
新建UserProvider,如果继承EloquentUserProvider,注入model是必须的,或者去继承interface,自己实现一些方法 use Illuminate\Auth\Eloq ...
- find principles
Computer Science An Overview _J. Glenn Brookshear _11th Edition In this chapter we explore the probl ...
- cookie 操作
//创建并赋值 重新赋值也是这样操作 document.cookie="userId=828"; document.cookie="userName=hulk" ...
- In App Purchase
参考文章1,参考文章2,参考文章3, 参考文章3 一.Product 分类: Consumables: 应该在应用里被消费掉的.(Coupon, 生命数) Non-Consumab ...
- 关于xampp使用不同端口的虚拟机
1.打开apache/conf/httpd.conf文件加入listen 8080(监听的端口号) 然后加入 # Virtual hostsInclude "conf/extra/httpd ...
- QcheckBox
#include "dialog.h" #include "ui_dialog.h" #include <QtCore> #include < ...
- 1011 最大公约数GCD
1011 最大公约数GCD 基准时间限制:1 秒 空间限制:131072 KB 输入2个正整数A,B,求A与B的最大公约数. Input 2个数A,B,中间用空格隔开.(1<= A,B < ...