MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / Triangle

Class Triangle

src/main/java/field/utility/SimpleVoronoi.java:811–952  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

809 }
810
811 static public class Triangle extends ArraySet<Pnt> {
812
813 private int idNumber; // The id number
814 private Pnt circumcenter = null; // The triangle's circumcenter
815
816 private static int idGenerator = 0; // Used to create id numbers
817 public static boolean moreInfo = false; // True iff more info in
818
819 // toString
820
821 /**
822 * @param vertices
823 * the vertices of the Triangle.
824 * @throws IllegalArgumentException
825 * if there are not three distinct vertices
826 */
827 public Triangle(Pnt... vertices) {
828 this(Arrays.asList(vertices));
829 }
830
831 /**
832 * @param collection
833 * a Collection holding the Simplex vertices
834 * @throws IllegalArgumentException
835 * if there are not three distinct vertices
836 */
837 public Triangle(Collection<? extends Pnt> collection) {
838 super(collection);
839 idNumber = idGenerator++;
840 if (this.size() != 3)
841 throw new IllegalArgumentException("Triangle must have 3 vertices");
842 }
843
844 @Override
845 public String toString() {
846 if (!moreInfo)
847 return "Triangle" + idNumber;
848 return "Triangle" + idNumber + super.toString();
849 }
850
851 /**
852 * Get arbitrary vertex of this triangle, but not any of the bad
853 * vertices.
854 *
855 * @param badVertices
856 * one or more bad vertices
857 * @return a vertex of this triangle, but not one of the bad
858 * vertices
859 * @throws NoSuchElementException
860 * if no vertex found
861 */
862 public Pnt getVertexButNot(Pnt... badVertices) {
863 Collection<Pnt> bad = Arrays.asList(badVertices);
864 for (Pnt v : this)
865 if (!bad.contains(v))
866 return v;
867 throw new NoSuchElementException("No vertex found");
868 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected