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.sift;
011
012public class SiftMatch implements Comparable<SiftMatch> {
013        
014        final SiftDescriptor descriptor1, descriptor2;
015        final double distance;
016        
017        public SiftMatch(SiftDescriptor descriptor1, SiftDescriptor descriptor2, double distance) {
018                this.descriptor1 = descriptor1;
019                this.descriptor2 = descriptor2;
020                this.distance = distance;
021        }
022        
023        public SiftDescriptor getDescriptor1() {
024                return descriptor1;
025        }
026        
027        public SiftDescriptor getDescriptor2() {
028                return descriptor2;
029        }
030        
031        public double getDistance() {
032                return distance;
033        }
034
035        public int compareTo(SiftMatch match2) {
036                if (this.distance < match2.distance)
037                        return -1;
038                else if (this.distance > match2.distance)
039                        return 1;
040                else
041                        return 0;
042        }
043        
044        public String toString() {
045                return String.format("match %.2f", this.distance);
046        }
047
048}