001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.geometry.core;
018
019/** Interface representing a point in a mathematical space.
020 *
021 * <p>Implementations of this interface are sufficient to define a
022 * space since they define both the structure of the points making up
023 * the space and the operations permitted on them. The only mathematical
024 * requirement at this level is that the represented space have a defined
025 * distance metric, meaning an operation that can compute the distance
026 * between two points (ie, the space must be a metric space).
027 * </p>
028 *
029 * <p>This interface uses self-referencing generic parameters to ensure
030 * that implementations are only used with instances of their own type.
031 * This removes the need for casting inside of methods in order to access
032 * implementation-specific data, such as coordinate values.
033 * </p>
034 *
035 * @see <a href="https://en.wikipedia.org/wiki/Metric_space">Metric space</a>
036 *
037 * @param <P> Point implementation type
038 */
039public interface Point<P extends Point<P>> extends Spatial {
040
041    /** Compute the distance between this point and another point.
042     * @param p second point
043     * @return the distance between this point and p
044     */
045    double distance(P p);
046}