    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     */
    017    package org.apache.commons.math3.geometry.partitioning;
    018
    019    import org.apache.commons.math3.geometry.Vector;
    020    import org.apache.commons.math3.geometry.Space;
    021
    022    /** This interface represents an hyperplane of a space.
    023
    024     * <p>The most prominent place where hyperplane appears in space
    025     * partitioning is as cutters. Each partitioning node in a {@link
    026     * BSPTree BSP tree} has a cut {@link SubHyperplane sub-hyperplane}
    027     * which is either an hyperplane or a part of an hyperplane. In an
    028     * n-dimensions euclidean space, an hyperplane is an (n-1)-dimensions
    029     * hyperplane (for example a traditional plane in the 3D euclidean
    030     * space). They can be more exotic objects in specific fields, for
    031     * example a circle on the surface of the unit sphere.</p>
    032
    033     * @param <S> Type of the space.
    034
    035     * @version $Id: Hyperplane.java 1416643 2012-12-03 19:37:14Z tn $
    036     * @since 3.0
    037     */
    038    public interface Hyperplane<S extends Space> {
    039
    040        /** Copy the instance.
    041         * <p>The instance created is completely independant of the original
    042         * one. A deep copy is used, none of the underlying objects are
    043         * shared (except for immutable objects).</p>
    044         * @return a new hyperplane, copy of the instance
    045         */
    046        Hyperplane<S> copySelf();
    047
    048        /** Get the offset (oriented distance) of a point.
    049         * <p>The offset is 0 if the point is on the underlying hyperplane,
    050         * it is positive if the point is on one particular side of the
    051         * hyperplane, and it is negative if the point is on the other side,
    052         * according to the hyperplane natural orientation.</p>
    053         * @param point point to check
    054         * @return offset of the point
    055         */
    056        double getOffset(Vector<S> point);
    057
    058        /** Check if the instance has the same orientation as another hyperplane.
    059         * <p>This method is expected to be called on parallel hyperplanes. The
    060         * method should <em>not</em> re-check for parallelism, only for
    061         * orientation, typically by testing something like the sign of the
    062         * dot-products of normals.</p>
    063         * @param other other hyperplane to check against the instance
    064         * @return true if the instance and the other hyperplane have
    065         * the same orientation
    066         */
    067        boolean sameOrientationAs(Hyperplane<S> other);
    068
    069        /** Build a sub-hyperplane covering the whole hyperplane.
    070         * @return a sub-hyperplane covering the whole hyperplane
    071         */
    072        SubHyperplane<S> wholeHyperplane();
    073
    074        /** Build a region covering the whole space.
    075         * @return a region containing the instance
    076         */
    077        Region<S> wholeSpace();
    078
    079    }