BoundaryProjection.java

  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.  * This is not the original file distributed by the Apache Software Foundation
  19.  * It has been modified by the Hipparchus project
  20.  */
  21. package org.hipparchus.geometry.partitioning;

  22. import org.hipparchus.geometry.Point;
  23. import org.hipparchus.geometry.Space;

  24. /** Class holding the result of point projection on region boundary.
  25.  * <p>This class is a simple placeholder, it does not provide any
  26.  * processing methods.</p>
  27.  * <p>Instances of this class are guaranteed to be immutable</p>
  28.  * @param <S> Type of the space.
  29.  * @param <P> Type of the points in space.
  30.  * @see AbstractRegion#projectToBoundary(Point)
  31.  */
  32. public class BoundaryProjection<S extends Space, P extends Point<S, P>> {

  33.     /** Original point. */
  34.     private final P original;

  35.     /** Projected point. */
  36.     private final P projected;

  37.     /** Offset of the point with respect to the boundary it is projected on. */
  38.     private final double offset;

  39.     /** Constructor from raw elements.
  40.      * @param original original point
  41.      * @param projected projected point
  42.      * @param offset offset of the point with respect to the boundary it is projected on
  43.      */
  44.     public BoundaryProjection(final P original, final P projected, final double offset) {
  45.         this.original  = original;
  46.         this.projected = projected;
  47.         this.offset    = offset;
  48.     }

  49.     /** Get the original point.
  50.      * @return original point
  51.      */
  52.     public P getOriginal() {
  53.         return original;
  54.     }

  55.     /** Projected point.
  56.      * @return projected point, or null if there are no boundary
  57.      */
  58.     public P getProjected() {
  59.         return projected;
  60.     }

  61.     /** Offset of the point with respect to the boundary it is projected on.
  62.      * <p>
  63.      * The offset with respect to the boundary is negative if the {@link
  64.      * #getOriginal() original point} is inside the region, and positive otherwise.
  65.      * </p>
  66.      * <p>
  67.      * If there are no boundary, the value is set to either {@code
  68.      * Double.POSITIVE_INFINITY} if the region is empty (i.e. all points are
  69.      * outside of the region) or {@code Double.NEGATIVE_INFINITY} if the region
  70.      * covers the whole space (i.e. all points are inside of the region).
  71.      * </p>
  72.      * @return offset of the point with respect to the boundary it is projected on
  73.      */
  74.     public double getOffset() {
  75.         return offset;
  76.     }

  77. }