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 java.text.MessageFormat; 20 21 import org.apache.commons.geometry.core.Transform; 22 import org.apache.commons.geometry.euclidean.threed.Bounds3D; 23 import org.apache.commons.geometry.euclidean.threed.Vector3D; 24 25 /** Class representing the span of a line in 3D Euclidean space. This is the set of all points 26 * contained by the line. 27 * 28 * <p>Instances of this class are guaranteed to be immutable.</p> 29 */ 30 final class LineSpanningSubset3D extends LineConvexSubset3D { 31 32 /** Construct a new instance for the given line. 33 * @param line line to construct the span for 34 */ 35 LineSpanningSubset3D(final Line3D line) { 36 super(line); 37 } 38 39 /** {@inheritDoc} 40 * 41 * <p>This method always returns {@code true}.</p> 42 */ 43 @Override 44 public boolean isInfinite() { 45 return true; 46 } 47 48 /** {@inheritDoc} 49 * 50 * <p>This method always returns {@code false}.</p> 51 */ 52 @Override 53 public boolean isFinite() { 54 return false; 55 } 56 57 /** {@inheritDoc} 58 * 59 * <p>This method always returns {@link Double#POSITIVE_INFINITY}.</p> 60 */ 61 @Override 62 public double getSize() { 63 return Double.POSITIVE_INFINITY; 64 } 65 66 /** {@inheritDoc} 67 * 68 * <p>This method always returns {@code null}.</p> 69 */ 70 @Override 71 public Vector3D getStartPoint() { 72 return null; 73 } 74 75 /** {@inheritDoc} 76 * 77 * <p>This method always returns {@link Double#NEGATIVE_INFINITY}.</p> 78 */ 79 @Override 80 public double getSubspaceStart() { 81 return Double.NEGATIVE_INFINITY; 82 } 83 84 /** {@inheritDoc} 85 * 86 * <p>This method always returns {@code null}.</p> 87 */ 88 @Override 89 public Vector3D getEndPoint() { 90 return null; 91 } 92 93 /** {@inheritDoc} 94 * 95 * <p>This method always returns {@link Double#POSITIVE_INFINITY}.</p> 96 */ 97 @Override 98 public double getSubspaceEnd() { 99 return Double.POSITIVE_INFINITY; 100 } 101 102 /** {@inheritDoc} 103 * 104 * <p>This method always returns {@code null}.</p> 105 */ 106 @Override 107 public Vector3D getCentroid() { 108 return null; // infinite; no center 109 } 110 111 /** {@inheritDoc} 112 * 113 * <p>This method always returns {@code null}.</p> 114 */ 115 @Override 116 public Bounds3D getBounds() { 117 return null; // infinite; no bounds 118 } 119 120 /** {@inheritDoc} */ 121 @Override 122 public LineSpanningSubset3D transform(final Transform<Vector3D> transform) { 123 return new LineSpanningSubset3D(getLine().transform(transform)); 124 } 125 126 /** {@inheritDoc} */ 127 @Override 128 public String toString() { 129 final Line3D line = getLine(); 130 131 return MessageFormat.format(Line3D.TO_STRING_FORMAT, 132 getClass().getSimpleName(), 133 line.getOrigin(), 134 line.getDirection()); 135 } 136 137 /** {@inheritDoc} */ 138 @Override 139 boolean containsAbscissa(final double abscissa) { 140 return true; 141 } 142 }