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 * http://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 package org.apache.commons.geometry.euclidean.threed.line; 18 19 import org.apache.commons.geometry.core.RegionEmbedding; 20 import org.apache.commons.geometry.core.Sized; 21 import org.apache.commons.geometry.core.partitioning.HyperplaneBoundedRegion; 22 import org.apache.commons.geometry.euclidean.oned.Vector1D; 23 import org.apache.commons.geometry.euclidean.threed.Bounds3D; 24 import org.apache.commons.geometry.euclidean.threed.Vector3D; 25 26 /** Class representing a subset of a line in 3D Euclidean space. For example, line segments, 27 * rays, and disjoint combinations of the two are line subsets. Line subsets may be finite or infinite. 28 */ 29 public abstract class LineSubset3D implements RegionEmbedding<Vector3D, Vector1D>, Sized { 30 /** The line containing this instance. */ 31 private final Line3D line; 32 33 /** Construct a new instance based on the given line. 34 * @param line line containing the instance 35 */ 36 LineSubset3D(final Line3D line) { 37 this.line = line; 38 } 39 40 /** Get the line containing this subset. 41 * @return the line containing this subset 42 */ 43 public Line3D getLine() { 44 return line; 45 } 46 47 /** {@inheritDoc} */ 48 @Override 49 public Vector3D toSpace(final Vector1D pt) { 50 return line.toSpace(pt); 51 } 52 53 /** {@inheritDoc} */ 54 @Override 55 public Vector1D toSubspace(final Vector3D pt) { 56 return line.toSubspace(pt); 57 } 58 59 /** Get the centroid, or geometric center, of the line subset or null if 60 * the subset is empty or infinite. 61 * @return the centroid of the line subset, or null if the subset is empty or 62 * infinite 63 */ 64 public abstract Vector3D getCentroid(); 65 66 /** Get the 3D bounding box of the line subset or null if the subset is 67 * empty or infinite. 68 * @return the 3D bounding box the line subset or null if the subset is 69 * empty or infinite 70 */ 71 public abstract Bounds3D getBounds(); 72 73 /** Get the subspace region for the instance. 74 * @return the subspace region for the instance 75 */ 76 @Override 77 public abstract HyperplaneBoundedRegion<Vector1D> getSubspaceRegion(); 78 }