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  /** Class holding the result of point projection on region boundary.
28   * <p>This class is a simple placeholder, it does not provide any
29   * processing methods.</p>
30   * <p>Instances of this class are guaranteed to be immutable</p>
31   * @param <S> Type of the space.
32   * @param <P> Type of the points in space.
33   * @see AbstractRegion#projectToBoundary(Point)
34   */
35  public class BoundaryProjection<S extends Space, P extends Point<S, P>> {
36  
37      /** Original point. */
38      private final P original;
39  
40      /** Projected point. */
41      private final P projected;
42  
43      /** Offset of the point with respect to the boundary it is projected on. */
44      private final double offset;
45  
46      /** Constructor from raw elements.
47       * @param original original point
48       * @param projected projected point
49       * @param offset offset of the point with respect to the boundary it is projected on
50       */
51      public BoundaryProjection(final P original, final P projected, final double offset) {
52          this.original  = original;
53          this.projected = projected;
54          this.offset    = offset;
55      }
56  
57      /** Get the original point.
58       * @return original point
59       */
60      public P getOriginal() {
61          return original;
62      }
63  
64      /** Projected point.
65       * @return projected point, or null if there are no boundary
66       */
67      public P getProjected() {
68          return projected;
69      }
70  
71      /** Offset of the point with respect to the boundary it is projected on.
72       * <p>
73       * The offset with respect to the boundary is negative if the {@link
74       * #getOriginal() original point} is inside the region, and positive otherwise.
75       * </p>
76       * <p>
77       * If there are no boundary, the value is set to either {@code
78       * Double.POSITIVE_INFINITY} if the region is empty (i.e. all points are
79       * outside of the region) or {@code Double.NEGATIVE_INFINITY} if the region
80       * covers the whole space (i.e. all points are inside of the region).
81       * </p>
82       * @return offset of the point with respect to the boundary it is projected on
83       */
84      public double getOffset() {
85          return offset;
86      }
87  
88  }