//This file is part of SECONDO. //Copyright (C) 2004, University in Hagen, Department of Computer Science, //Database Systems for New Applications. //SECONDO is free software; you can redistribute it and/or modify //it under the terms of the GNU General Public License as published by //the Free Software Foundation; either version 2 of the License, or //(at your option) any later version. //SECONDO is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. //You should have received a copy of the GNU General Public License //along with SECONDO; if not, write to the Free Software //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA package fuzzyobjects.basic; import fuzzyobjects.*; import java.util.Vector; /** * this class provides points for a fixed triangulation of a * subset of euclidian space. * This triangulation is called the X-triangulation. * @author Thomas Behr */ public class BasicPoint implements BasicObject{ /** * creates a new BasicPoint on (x,y) * here is no check wether (x,y) is a valid BasicPoint * @param x the x-coordinate of the new point * @param y the y-coordinate of the new point * @see #isValid() */ public BasicPoint(int x,int y) { this.x = x; this.y = y; } /** * computes the BasicPoints of this BasicPoint * @return a array of length 1 with a copy of this as content */ public BasicPoint[] getBasicPoints(){ // return a array with a copy from this as element BasicPoint[] Ps = new BasicPoint[1]; Ps[0] = this.copy(); return Ps; } /** * convert this point in a readable form * @return a String representing this point */ public String toString(){ // no comment return "BP : ("+x+","+y+")"; } /** * computes a copy of this * @return a new BasicPoint on the same location as this */ public BasicPoint copy() { return new BasicPoint(x,y); } /** * check for equality * @param B the another BasicPoint * @return true if B is on the same location as this * otherwise false */ public boolean equals(BasicPoint B) { return x==B.x & y==B.y; } /** * computes the distance to a another BasicObject * @param BO the another BasicObject * @return the smallest euclidic distance between this and all * BasicPoints from BO * @see #q_euclid_distance(BasicObject) */ public double euclid_distance(BasicObject BO) { // returns the smallest euclidic distance from this to // all Basicpoints from BO return Math.sqrt(q_euclid_distance(BO)); } /** * computes the quadratic euclidic distance to * another BasicObject * @param BO the another BasicObject * @return the square of the smallest euclidic distance to all * BasicPoints from BO * @see #euclid_distance(BasicObject) */ public double q_euclid_distance(BasicObject BO) { // get the quadratic euclidic distance BasicPoint[] BPs = BO.getBasicPoints(); double min = ( (BPs[0].x-x)*(BPs[0].x-x) +(BPs[0].y-y)*(BPs[0].y-y) ); double current; for(int i=1;i *
  • -1 if O not a BasicPoint or this is smaller then O
  • *
  • 0 if this equals to O
  • *
  • 1 if O is a BasicPoint and this greater then O
  • * */ public int compareTo(BasicObject O){ if(!(O instanceof BasicPoint)) return -1; BasicPoint BP = (BasicPoint) O; if ((x2) * @param Bps to sorted array of BasicPoints * @return the sorted array */ public static void sort( BasicPoint[] BPs) { for (int i=0; i