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