LineSpanningSubset3D.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.  *      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. import java.text.MessageFormat;

  19. import org.apache.commons.geometry.core.Transform;
  20. import org.apache.commons.geometry.euclidean.threed.Bounds3D;
  21. import org.apache.commons.geometry.euclidean.threed.Vector3D;

  22. /** Class representing the span of a line in 3D Euclidean space. This is the set of all points
  23.  * contained by the line.
  24.  *
  25.  * <p>Instances of this class are guaranteed to be immutable.</p>
  26.  */
  27. final class LineSpanningSubset3D extends LineConvexSubset3D {

  28.     /** Construct a new instance for the given line.
  29.      * @param line line to construct the span for
  30.      */
  31.     LineSpanningSubset3D(final Line3D line) {
  32.         super(line);
  33.     }

  34.     /** {@inheritDoc}
  35.     *
  36.     * <p>This method always returns {@code true}.</p>
  37.     */
  38.     @Override
  39.     public boolean isInfinite() {
  40.         return true;
  41.     }

  42.     /** {@inheritDoc}
  43.     *
  44.     * <p>This method always returns {@code false}.</p>
  45.     */
  46.     @Override
  47.     public boolean isFinite() {
  48.         return false;
  49.     }

  50.     /** {@inheritDoc}
  51.     *
  52.     * <p>This method always returns {@link Double#POSITIVE_INFINITY}.</p>
  53.     */
  54.     @Override
  55.     public double getSize() {
  56.         return Double.POSITIVE_INFINITY;
  57.     }

  58.     /** {@inheritDoc}
  59.     *
  60.     * <p>This method always returns {@code null}.</p>
  61.     */
  62.     @Override
  63.     public Vector3D getStartPoint() {
  64.         return null;
  65.     }

  66.     /** {@inheritDoc}
  67.     *
  68.     * <p>This method always returns {@link Double#NEGATIVE_INFINITY}.</p>
  69.     */
  70.     @Override
  71.     public double getSubspaceStart() {
  72.         return Double.NEGATIVE_INFINITY;
  73.     }

  74.     /** {@inheritDoc}
  75.     *
  76.     * <p>This method always returns {@code null}.</p>
  77.     */
  78.     @Override
  79.     public Vector3D getEndPoint() {
  80.         return null;
  81.     }

  82.     /** {@inheritDoc}
  83.      *
  84.      * <p>This method always returns {@link Double#POSITIVE_INFINITY}.</p>
  85.      */
  86.     @Override
  87.     public double getSubspaceEnd() {
  88.         return Double.POSITIVE_INFINITY;
  89.     }

  90.     /** {@inheritDoc}
  91.      *
  92.      * <p>This method always returns {@code null}.</p>
  93.      */
  94.     @Override
  95.     public Vector3D getCentroid() {
  96.         return null; // infinite; no center
  97.     }

  98.     /** {@inheritDoc}
  99.     *
  100.     * <p>This method always returns {@code null}.</p>
  101.     */
  102.     @Override
  103.     public Bounds3D getBounds() {
  104.         return null; // infinite; no bounds
  105.     }

  106.     /** {@inheritDoc} */
  107.     @Override
  108.     public LineSpanningSubset3D transform(final Transform<Vector3D> transform) {
  109.         return new LineSpanningSubset3D(getLine().transform(transform));
  110.     }

  111.     /** {@inheritDoc} */
  112.     @Override
  113.     public String toString() {
  114.         final Line3D line = getLine();

  115.         return MessageFormat.format(Line3D.TO_STRING_FORMAT,
  116.                 getClass().getSimpleName(),
  117.                 line.getOrigin(),
  118.                 line.getDirection());
  119.     }

  120.     /** {@inheritDoc} */
  121.     @Override
  122.     boolean containsAbscissa(final double abscissa) {
  123.         return true;
  124.     }
  125. }