All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.commons.geometry.euclidean.twod.LineSpanningSubset Maven / Gradle / Ivy

The newest version!
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.commons.geometry.euclidean.twod;

import java.text.MessageFormat;

import org.apache.commons.geometry.core.RegionLocation;
import org.apache.commons.geometry.core.Transform;
import org.apache.commons.geometry.core.partitioning.Split;

/** Class representing the span of a line in 2D Euclidean space. This is the set of all points
 * contained by the line.
 *
 * 

Instances of this class are guaranteed to be immutable.

*/ final class LineSpanningSubset extends LineConvexSubset { /** Construct a new instance for the given line. * @param line line to construct the span for */ LineSpanningSubset(final Line line) { super(line); } /** {@inheritDoc} * *

This method always returns {@code true}.

*/ @Override public boolean isFull() { return true; } /** {@inheritDoc} * *

This method always returns {@code true}.

*/ @Override public boolean isInfinite() { return true; } /** {@inheritDoc} * *

This method always returns {@code false}.

*/ @Override public boolean isFinite() { return false; } /** {@inheritDoc} * *

This method always returns {@link Double#POSITIVE_INFINITY}.

*/ @Override public double getSize() { return Double.POSITIVE_INFINITY; } /** {@inheritDoc} * *

This method always returns {@code null}.

*/ @Override public Vector2D getCentroid() { return null; } /** {@inheritDoc} * *

This method always returns {@code null}.

*/ @Override public Vector2D getStartPoint() { return null; } /** {@inheritDoc} * *

This method always returns {@link Double#NEGATIVE_INFINITY}.

*/ @Override public double getSubspaceStart() { return Double.NEGATIVE_INFINITY; } /** {@inheritDoc} * *

This method always returns {@code null}.

*/ @Override public Vector2D getEndPoint() { return null; } /** {@inheritDoc} * *

This method always returns {@link Double#POSITIVE_INFINITY}.

*/ @Override public double getSubspaceEnd() { return Double.POSITIVE_INFINITY; } /** {@inheritDoc} * *

This method always returns {@code null}.

*/ @Override public Bounds2D getBounds() { return null; // infinite; no bounds } /** {@inheritDoc} */ @Override public LineSpanningSubset transform(final Transform transform) { return new LineSpanningSubset(getLine().transform(transform)); } /** {@inheritDoc} */ @Override public LineSpanningSubset reverse() { return new LineSpanningSubset(getLine().reverse()); } /** {@inheritDoc} */ @Override public String toString() { final Line line = getLine(); return MessageFormat.format(Line.TO_STRING_FORMAT, getClass().getSimpleName(), line.getOrigin(), line.getDirection()); } /** {@inheritDoc} */ @Override RegionLocation classifyAbscissa(final double abscissa) { return RegionLocation.INSIDE; } /** {@inheritDoc} */ @Override double closestAbscissa(final double abscissa) { return abscissa; } /** {@inheritDoc} */ @Override Split splitOnIntersection(final Line splitter, final Vector2D intersection) { final Line line = getLine(); final ReverseRay low = new ReverseRay(line, intersection); final Ray high = new Ray(line, intersection); return createSplitResult(splitter, low, high); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy