001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.math3.geometry.partitioning; 018 019import org.apache.commons.math3.geometry.Point; 020import org.apache.commons.math3.geometry.Space; 021 022/** Class holding the result of point projection on region boundary. 023 * <p>This class is a simple placeholder, it does not provide any 024 * processing methods.</p> 025 * <p>Instances of this class are guaranteed to be immutable</p> 026 * @param <S> Type of the space. 027 * @since 3.3 028 * @see AbstractRegion#projectToBoundary(Point) 029 */ 030public class BoundaryProjection<S extends Space> { 031 032 /** Original point. */ 033 private final Point<S> original; 034 035 /** Projected point. */ 036 private final Point<S> projected; 037 038 /** Offset of the point with respect to the boundary it is projected on. */ 039 private final double offset; 040 041 /** Constructor from raw elements. 042 * @param original original point 043 * @param projected projected point 044 * @param offset offset of the point with respect to the boundary it is projected on 045 */ 046 public BoundaryProjection(final Point<S> original, final Point<S> projected, final double offset) { 047 this.original = original; 048 this.projected = projected; 049 this.offset = offset; 050 } 051 052 /** Get the original point. 053 * @return original point 054 */ 055 public Point<S> getOriginal() { 056 return original; 057 } 058 059 /** Projected point. 060 * @return projected point, or null if there are no boundary 061 */ 062 public Point<S> getProjected() { 063 return projected; 064 } 065 066 /** Offset of the point with respect to the boundary it is projected on. 067 * <p> 068 * The offset with respect to the boundary is negative if the {@link 069 * #getOriginal() original point} is inside the region, and positive otherwise. 070 * </p> 071 * <p> 072 * If there are no boundary, the value is set to either {@code 073 * Double.POSITIVE_INFINITY} if the region is empty (i.e. all points are 074 * outside of the region) or {@code Double.NEGATIVE_INFINITY} if the region 075 * covers the whole space (i.e. all points are inside of the region). 076 * </p> 077 * @return offset of the point with respect to the boundary it is projected on 078 */ 079 public double getOffset() { 080 return offset; 081 } 082 083}