|
Java example source code file (SubLine.java)
The SubLine.java Java example source code/* * 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.math3.geometry.euclidean.twod; import java.util.ArrayList; import java.util.List; import org.apache.commons.math3.geometry.Point; import org.apache.commons.math3.geometry.euclidean.oned.Euclidean1D; import org.apache.commons.math3.geometry.euclidean.oned.Interval; import org.apache.commons.math3.geometry.euclidean.oned.IntervalsSet; import org.apache.commons.math3.geometry.euclidean.oned.OrientedPoint; import org.apache.commons.math3.geometry.euclidean.oned.Vector1D; import org.apache.commons.math3.geometry.partitioning.AbstractSubHyperplane; import org.apache.commons.math3.geometry.partitioning.BSPTree; import org.apache.commons.math3.geometry.partitioning.Hyperplane; import org.apache.commons.math3.geometry.partitioning.Region; import org.apache.commons.math3.geometry.partitioning.Region.Location; import org.apache.commons.math3.geometry.partitioning.SubHyperplane; import org.apache.commons.math3.util.FastMath; /** This class represents a sub-hyperplane for {@link Line}. * @since 3.0 */ public class SubLine extends AbstractSubHyperplane<Euclidean2D, Euclidean1D> { /** Default value for tolerance. */ private static final double DEFAULT_TOLERANCE = 1.0e-10; /** Simple constructor. * @param hyperplane underlying hyperplane * @param remainingRegion remaining region of the hyperplane */ public SubLine(final Hyperplane<Euclidean2D> hyperplane, final Region<Euclidean1D> remainingRegion) { super(hyperplane, remainingRegion); } /** Create a sub-line from two endpoints. * @param start start point * @param end end point * @param tolerance tolerance below which points are considered identical * @since 3.3 */ public SubLine(final Vector2D start, final Vector2D end, final double tolerance) { super(new Line(start, end, tolerance), buildIntervalSet(start, end, tolerance)); } /** Create a sub-line from two endpoints. * @param start start point * @param end end point * @deprecated as of 3.3, replaced with {@link #SubLine(Vector2D, Vector2D, double)} */ @Deprecated public SubLine(final Vector2D start, final Vector2D end) { this(start, end, DEFAULT_TOLERANCE); } /** Create a sub-line from a segment. * @param segment single segment forming the sub-line */ public SubLine(final Segment segment) { super(segment.getLine(), buildIntervalSet(segment.getStart(), segment.getEnd(), segment.getLine().getTolerance())); } /** Get the endpoints of the sub-line. * <p> * A subline may be any arbitrary number of disjoints segments, so the endpoints * are provided as a list of endpoint pairs. Each element of the list represents * one segment, and each segment contains a start point at index 0 and an end point * at index 1. If the sub-line is unbounded in the negative infinity direction, * the start point of the first segment will have infinite coordinates. If the * sub-line is unbounded in the positive infinity direction, the end point of the * last segment will have infinite coordinates. So a sub-line covering the whole * line will contain just one row and both elements of this row will have infinite * coordinates. If the sub-line is empty, the returned list will contain 0 segments. * </p> * @return list of segments endpoints */ public List<Segment> getSegments() { final Line line = (Line) getHyperplane(); final List<Interval> list = ((IntervalsSet) getRemainingRegion()).asList(); final List<Segment> segments = new ArrayList Other Java examples (source code examples)Here is a short list of links related to this Java SubLine.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.