001/*******************************************************************************
002 * This software is provided as a supplement to the authors' textbooks on digital
003 *  image processing published by Springer-Verlag in various languages and editions.
004 * Permission to use and distribute this software is granted under the BSD 2-Clause 
005 * "Simplified" License (see http://opensource.org/licenses/BSD-2-Clause). 
006 * Copyright (c) 2006-2016 Wilhelm Burger, Mark J. Burge. All rights reserved. 
007 * Visit http://imagingbook.com for additional details.
008 *******************************************************************************/
009
010package imagingbook.pub.corners;
011
012/**
013 * 2013/06/09 Changed to 'final float' coordinates (WB).
014 */
015public class Corner implements Comparable<Corner> {
016        protected final float x, y, q;
017
018        public float getX() {
019                return x;
020        }
021
022        public float getY() {
023                return y;
024        }
025
026        public float getQ() {
027                return q;
028        }
029        
030        public Corner (float x, float y, float q) {
031                this.x = x;
032                this.y = y;
033                this.q = q;
034        }
035    
036        public int compareTo (Corner c2) {
037                //used for sorting corners by corner strength q
038                if (this.q > c2.q) return -1;
039                if (this.q < c2.q) return 1;
040                else return 0;
041        }
042        
043        double dist2 (Corner c2){
044                //returns the squared distance between this corner and corner c2
045                float dx = this.x - c2.x;
046                float dy = this.y - c2.y;
047                return (dx * dx) + (dy * dy);   
048        }
049}