道格拉斯普克算法设计
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;
using System.Collections;
using System.IO;
namespace douglas
{
public partial class Form1 : Form
{
int num;
double xmax, ymax;
ArrayList myar = new ArrayList();
ArrayList newar = new ArrayList();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
public canshu xielv(zuobiao shou, zuobiao wei)
{
double k, b;
canshu newcs = new canshu();
k = (wei.y - shou.y) / (wei.x - shou.x);
b = shou.y - k * shou.x;
newcs.k = k;
newcs.b = b;
return newcs;
}
public double distance(zuobiao dot,canshu cs)
{
double dis =(Math.Abs (cs.k * dot.x - dot.y + cs.b)) / Math.Sqrt(cs.k * cs.k + 1);
评论1