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   * @param <P> Type of the points in space.
47   * @param <H> Type of the hyperplane.
48   * @param <I> Type of the sub-hyperplane.
49  
50   */
51  public interface Hyperplane<S extends Space,
52                              P extends Point<S, P>,
53                              H extends Hyperplane<S, P, H, I>,
54                              I extends SubHyperplane<S, P, H, I>> {
55  
56      /** Copy the instance.
57       * <p>The instance created is completely independent of the original
58       * one. A deep copy is used, none of the underlying objects are
59       * shared (except for immutable objects).</p>
60       * @return a new hyperplane, copy of the instance
61       */
62      H copySelf();
63  
64      /** Get the offset (oriented distance) of a point.
65       * <p>The offset is 0 if the point is on the underlying hyperplane,
66       * it is positive if the point is on one particular side of the
67       * hyperplane, and it is negative if the point is on the other side,
68       * according to the hyperplane natural orientation.</p>
69       * @param point point to check
70       * @return offset of the point
71       */
72      double getOffset(P point);
73  
74      /** Move point up to specified offset.
75       * <p>
76       * Motion is <em>orthogonal</em> to the hyperplane
77       * </p>
78       * @param point point to move
79       * @param offset desired offset
80       * @return moved point at desired offset
81       * @since 4.0
82       */
83      P moveToOffset(P point, double offset);
84  
85      /** Get an arbitrary point in the hyperplane.
86       * @return arbirary point in the hyperplane
87       * @since 4.0
88       */
89      P arbitraryPoint();
90  
91      /** Project a point to the hyperplane.
92       * @param point point to project
93       * @return projected point
94       */
95      P project(P point);
96  
97      /** Get the tolerance below which points are considered to belong to the hyperplane.
98       * @return tolerance below which points are considered to belong to the hyperplane
99       */
100     double getTolerance();
101 
102     /** Check if the instance has the same orientation as another hyperplane.
103      * <p>This method is expected to be called on parallel hyperplanes. The
104      * method should <em>not</em> re-check for parallelism, only for
105      * orientation, typically by testing something like the sign of the
106      * dot-products of normals.</p>
107      * @param other other hyperplane to check against the instance
108      * @return true if the instance and the other hyperplane have
109      * the same orientation
110      */
111     boolean sameOrientationAs(H other);
112 
113     /** Build a sub-hyperplane covering the whole hyperplane.
114      * @return a sub-hyperplane covering the whole hyperplane
115      */
116     I wholeHyperplane();
117 
118     /** Build a sub-hyperplane covering nothing.
119      * @return a sub-hyperplane covering nothing
120      * @since 1.4
121      */
122     I emptyHyperplane();
123 
124     /** Build a region covering the whole space.
125      * @return a region containing the instance
126      */
127     Region<S, P, H, I> wholeSpace();
128 
129 }