JavaCAD
HalfEdge.java
Go to the documentation of this file.
1  /*
2  * Copyright John E. Lloyd, 2003. All rights reserved. Permission
3  * to use, copy, and modify, without fee, is granted for non-commercial
4  * and research purposes, provided that this copyright notice appears
5  * in all copies.
6  *
7  * This software is distributed "as is", without any warranty, including
8  * any implied warranty of merchantability or fitness for a particular
9  * use. The authors assume no responsibility for, and shall not be liable
10  * for, any special, indirect, or consequential damages, or any damages
11  * whatsoever, arising out of or in connection with the use of this
12  * software.
13  */
14 
15 package eu.mihosoft.vrl.v3d.ext.quickhull3d;
16 
17 // TODO: Auto-generated Javadoc
23 class HalfEdge
24 {
28  Vertex vertex;
29 
33  Face face;
34 
38  HalfEdge next;
39 
43  HalfEdge prev;
44 
49  HalfEdge opposite;
50 
58  public HalfEdge (Vertex v, Face f)
59  {
60  vertex = v;
61  face = f;
62  }
63 
67  public HalfEdge ()
68  {
69  }
70 
76  public void setNext (HalfEdge edge)
77  {
78  next = edge;
79  }
80 
86  public HalfEdge getNext()
87  {
88  return next;
89  }
90 
96  public void setPrev (HalfEdge edge)
97  {
98  prev = edge;
99  }
100 
107  public HalfEdge getPrev()
108  {
109  return prev;
110  }
111 
118  public Face getFace()
119  {
120  return face;
121  }
122 
128  public HalfEdge getOpposite()
129  {
130  return opposite;
131  }
132 
138  public void setOpposite (HalfEdge edge)
139  {
140  opposite = edge;
141  edge.opposite = this;
142  }
143 
149  public Vertex head()
150  {
151  return vertex;
152  }
153 
159  public Vertex tail()
160  {
161  return prev != null ? prev.vertex : null;
162  }
163 
170  public Face oppositeFace()
171  {
172  return opposite != null ? opposite.face : null;
173  }
174 
181  public String getVertexString()
182  {
183  if (tail() != null)
184  { return "" +
185  tail().index + "-" +
186  head().index;
187  }
188  else
189  { return "?-" + head().index;
190  }
191  }
192 
198  public double length()
199  {
200  if (tail() != null)
201  { return head().pnt.distance(tail().pnt);
202  }
203  else
204  { return -1;
205  }
206  }
207 
213  public double lengthSquared()
214  {
215  if (tail() != null)
216  { return head().pnt.distanceSquared(tail().pnt);
217  }
218  else
219  { return -1;
220  }
221  }
222 
223 
224 // /**
225 // * Computes nrml . (del0 X del1), where del0 and del1
226 // * are the direction vectors along this halfEdge, and the
227 // * halfEdge he1.
228 // *
229 // * A product > 0 indicates a left turn WRT the normal
230 // */
231 // public double turnProduct (HalfEdge he1, Vector3d nrml)
232 // {
233 // Point3d pnt0 = tail().pnt;
234 // Point3d pnt1 = head().pnt;
235 // Point3d pnt2 = he1.head().pnt;
236 
237 // double del0x = pnt1.x - pnt0.x;
238 // double del0y = pnt1.y - pnt0.y;
239 // double del0z = pnt1.z - pnt0.z;
240 
241 // double del1x = pnt2.x - pnt1.x;
242 // double del1y = pnt2.y - pnt1.y;
243 // double del1z = pnt2.z - pnt1.z;
244 
245 // return (nrml.x*(del0y*del1z - del0z*del1y) +
246 // nrml.y*(del0z*del1x - del0x*del1z) +
247 // nrml.z*(del0x*del1y - del0y*del1x));
248 // }
249 }
250 
251