有p1,p2两点,粗为5px构成的线,怎么判断点p是否在直线上
解决方案 »
- C#中如何循环输出控件??
- 请问ajax toolkit里的日历控件,可以同时映射到两个文本框吗
- 工具栏控件toolStrip1中下拉列表控件toolStripComboBox1如何编程显示toolTip提示信息
- ***System.Diagnostics.Process调用exe之后怎么取得exe的返回值?
- windows应用程序中怎么实现datagride中添加button控件(急)
- dataGird导出到EXCEL的问题
- PCI扩展空间怎么读?
- 急需
- 我做了一个dll。但为什么public方法无法调用啊?
- gridview在增加记录后不刷新页面时自动将数据显示在gridview上(高难度)100分
- 队列 菜鸟问题 高手大大的进
- 菜鸟问题
Point _P2;
Point _Point; Point _StarPoint1 = new Point(P1.X + 5, P1.Y - 5);
Point _StarPoint2 = new Point(P1.X - 5, P1.Y + 5);
Point _EndPoint1 = new Point(P2.X + 5, P2.Y - 5);
Point _EndPoint2 = new Point(P2.X - 5, P2.Y + 5);
System.Drawing.Drawing2D.GraphicsPath _GraphicsPath = new System.Drawing.Drawing2D.GraphicsPath(); //获得一个多边形状
Region _Region = new Region();
_GraphicsPath.Reset();
_GraphicsPath.AddPolygon(new Point[] { _StarPoint1, _StarPoint2, _EndPoint1, _EndPoint2 });
_Region.MakeEmpty();
_Region.Union(_GraphicsPath);
MessageBox.Show(_Region.IsVisible(_Point).ToString()); //返回判断点是否在多边形里
{
if (x1 == x2 && y1 == y2) //已知两点是重复的两点
return false;
else if (x1 == x2)//与X轴垂直,斜率无穷大
{
if (x == x1)
return true;
else
return false;
}
else if (y1 == y2)//与X轴平行,斜率为0
{
if (y == y1)
return true;
else
return false;
}
else
{
if (x == x1 && y != y1)
return false;
else if (x == x1&&y==y1)
return true;
else if (Convert.ToDouble(y1 - y2) / Convert.ToDouble(x1 - x2) == Convert.ToDouble(y1 - y) / Convert.ToDouble(x1 - x))
{
return true;
}
}
return false;
}
panduan(1,1,5,1,6,1) => true
还有线条粗细不考虑?
| /\
P1 / \
/|\C \
B /_X/ \
\ / \
D\ \F
\ /
\ /
\ /
\/
E
AB=5
P1B=2.5
P1BDC的对象线的一半BX=P1B/cos(45度)=2.5/cos(45度)
P1X=tan(45度)*P1B=tan(45度)*2.5所以B点坐标是(P1.X-BX,P1.Y+P1X)
其它3个点也同理求出通过2个点得到面Rectangle R = new Rectangle(左上角坐标x,左上角坐标y,右下角坐标x,右下角坐标y);最后判断点是否在面内
if (R.Contains(new Point(10, 10)))
Region region = null;
using (GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath()) {
gp.AddLine(Beg, End);
using (Pen p = new Pen(Color.Black, 5)) {
gp.Widen(p);
using (region = new Region(gp)) {
return region.IsVisible(pos); // 判断点是否落在线上
}
}
}精简了一些检查, 比如 Beg, End 是否重合之类的, 不过大体思路 就是这样
| / B点
| /
A点|/
计算他们的夹角度数是多少?
这样不知可以计算不??
http://topic.csdn.net/u/20081208/12/e8f9d5b5-057a-44ef-9d84-44aea7a22fce.html
这里面的二楼很详细
好像是,不过还要判断范围 如果这样就不是 A(x,y)
\ 2
P
[]
[]
[]
[]
[]