00001 using System;
00002 using System.Collections.Generic;
00003 using System.Linq;
00004 using System.Text;
00005 using System.Windows;
00006
00007 namespace EdgeClustering
00008 {
00009
00010
00011
00012
00013
00014
00015 public class SimpleEdge : IEquatable<SimpleEdge>
00016 {
00017 private Point a, b;
00018 private Vector v;
00019 private double alpha;
00020
00021
00022
00023
00024 public Point A
00025 {
00026 get { return a; }
00027 set { a = value; update(); }
00028 }
00029
00030
00031
00032
00033 public Point B
00034 {
00035 get { return b; }
00036 set { b = value; update(); }
00037 }
00038
00039
00040
00041
00042 public Vector V
00043 {
00044 get { return v; }
00045 }
00046
00047
00048
00049
00050 public double Alpha
00051 {
00052 get { return alpha; }
00053 }
00054
00055
00056 private void update()
00057 {
00058 if (a != null && b != null)
00059 {
00060 v = b - a;
00061 v.Normalize();
00062
00063
00064
00065 alpha = (v.Y >= 0) ? Math.Acos(v.X) : Math.Acos(-v.X);
00066 alpha *= 180.0 / Math.PI;
00067 }
00068 }
00069 public SimpleEdge(Point a,Point b)
00070 {
00071 this.a = a;
00072 this.b = b;
00073 update();
00074 }
00075
00076 public bool Equals(SimpleEdge other)
00077 {
00078 return this.A.Equals(other.A) && this.B.Equals(other.B) || this.A.Equals(other.B) && this.B.Equals(other.A);
00079 }
00080 }
00081 }