示例#1
0
        public Face Search(Vertex vertex)
        {
            if (!Root.Face.Inside(vertex))
                return null;

            return Search(Root, vertex).Face;
        }
示例#2
0
        public void Add(Vertex vertex, params Face[] faces )
        {
            Node node = Search(Root, vertex);

            foreach (Face face in faces)
            {
                node.Children.Add(new Node(face));
            }
        }
示例#3
0
        private Node Search(Node node, Vertex vertex)
        {
            foreach (Node childNode in node.Children)
            {
                if (childNode.Face.Inside(vertex))
                {
                    return Search(childNode, vertex);
                }
            }

            return node;
        }
示例#4
0
        public bool Inside(Vertex p)
        {
            int i, j = Vertices.Count - 1;
            bool oddNodes = false;

            for (i = 0; i < Vertices.Count; i++)
            {
                if (((Vertices[i].Y < p.Y && Vertices[j].Y >= p.Y) || (Vertices[j].Y < p.Y && Vertices[i].Y >= p.Y)) &&
                    (Vertices[i].X <= p.X || Vertices[j].X <= p.X))
                    oddNodes ^= Vertices[i].X +
                                (p.Y - Vertices[i].Y)/(Vertices[j].Y - Vertices[i].Y)*(Vertices[j].X - Vertices[i].X) <
                                p.X;
                j = i;
            }

            return oddNodes;
        }
示例#5
0
 public float Cross(Vertex v)
 {
     return X*v.Y - Y*v.X;
 }
示例#6
0
 public float DistanceSquared(Vertex vertex)
 {
     float dx = X - vertex.X;
     float dy = Y - vertex.Y;
     return dx*dx + dy*dy;
 }
示例#7
0
 public float ManhattanDistance(Vertex vertex) => Convert.ToSingle(Math.Abs(X - vertex.X) + Math.Abs(Y - vertex.Y));
示例#8
0
 public float Distance(Vertex vertex) => Convert.ToSingle(Math.Sqrt(DistanceSquared(vertex)));
示例#9
0
 public bool Equals(Vertex v)
 {
     return this.X == v.X && this.Y == v.Y;
 }
示例#10
0
 public Vertex(Vertex v)
 {
     X = v.X;
     Y = v.Y;
 }
示例#11
0
 public static float Distance(Vertex v1, Vertex v2)
 {
     return Convert.ToSingle(Math.Sqrt((v2.X - v1.X)*(v2.X - v1.X) + (v2.Y - v1.Y)*(v2.Y - v1.Y)));
 }
示例#12
0
 public static float Slope(Vertex v1, Vertex v2)
 {
     float value = (v2.Y - v1.Y)/(v2.X - v1.X);
     return value;
 }
示例#13
0
 public static Vertex Midpoint(Vertex v1, Vertex v2)
 {
     float mx = v1.X/2 + v2.X/2;
     float my = v1.Y/2 + v2.Y/2;
     return new Vertex(mx, my);
 }
示例#14
0
 public bool Contains(Vertex vertex)
 {
     return Vertices.Contains(vertex);
 }
示例#15
0
 public Edge(Vertex v1, Vertex v2)
 {
     V1 = v1;
     V2 = v2;
 }