C#中判断点在直线上的方法比较多,算法因人而异,我自己写的一个是判断待测点与两个端点的直线的长度的和与原直线的长度之差,程序主要计算是计算两点的距离代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Point p1 = new Point(int.Par