View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      https://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  /*
19   * This is not the original file distributed by the Apache Software Foundation
20   * It has been modified by the Hipparchus project
21   */
22  package org.hipparchus.geometry.partitioning;
23  
24  import org.hipparchus.geometry.Point;
25  import org.hipparchus.geometry.Space;
26  
27  /** This interface represents an hyperplane of a space.
28  
29   * <p>The most prominent place where hyperplane appears in space
30   * partitioning is as cutters. Each partitioning node in a {@link
31   * BSPTree BSP tree} has a cut {@link SubHyperplane sub-hyperplane}
32   * which is either an hyperplane or a part of an hyperplane. In an
33   * n-dimensions euclidean space, an hyperplane is an (n-1)-dimensions
34   * hyperplane (for example a traditional plane in the 3D euclidean
35   * space). They can be more exotic objects in specific fields, for
36   * example a circle on the surface of the unit sphere.</p>
37  
38   * <p>
39   * Note that this interface is <em>not</em> intended to be implemented
40   * by Hipparchus users, it is only intended to be implemented
41   * within the library itself. New methods may be added even for minor
42   * versions, which breaks compatibility for external implementations.
43   * </p>
44  
45   * @param <S> Type of the space.
46  
47   */
48  public interface Hyperplane<S extends Space> {
49  
50      /** Copy the instance.
51       * <p>The instance created is completely independant of the original
52       * one. A deep copy is used, none of the underlying objects are
53       * shared (except for immutable objects).</p>
54       * @return a new hyperplane, copy of the instance
55       */
56      Hyperplane<S> copySelf();
57  
58      /** Get the offset (oriented distance) of a point.
59       * <p>The offset is 0 if the point is on the underlying hyperplane,
60       * it is positive if the point is on one particular side of the
61       * hyperplane, and it is negative if the point is on the other side,
62       * according to the hyperplane natural orientation.</p>
63       * @param point point to check
64       * @return offset of the point
65       */
66      double getOffset(Point<S> point);
67  
68      /** Project a point to the hyperplane.
69       * @param point point to project
70       * @return projected point
71       */
72      Point<S> project(Point<S> point);
73  
74      /** Get the tolerance below which points are considered to belong to the hyperplane.
75       * @return tolerance below which points are considered to belong to the hyperplane
76       */
77      double getTolerance();
78  
79      /** Check if the instance has the same orientation as another hyperplane.
80       * <p>This method is expected to be called on parallel hyperplanes. The
81       * method should <em>not</em> re-check for parallelism, only for
82       * orientation, typically by testing something like the sign of the
83       * dot-products of normals.</p>
84       * @param other other hyperplane to check against the instance
85       * @return true if the instance and the other hyperplane have
86       * the same orientation
87       */
88      boolean sameOrientationAs(Hyperplane<S> other);
89  
90      /** Build a sub-hyperplane covering the whole hyperplane.
91       * @return a sub-hyperplane covering the whole hyperplane
92       */
93      SubHyperplane<S> wholeHyperplane();
94  
95      /** Build a sub-hyperplane covering nothing.
96       * @return a sub-hyperplane covering nothing
97       * @since 1.4
98       */
99      SubHyperplane<S> emptyHyperplane();
100 
101     /** Build a region covering the whole space.
102      * @return a region containing the instance
103      */
104     Region<S> wholeSpace();
105 
106 }