|
Java example source code file (MonotoneChain.java)
The MonotoneChain.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.hull; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.List; import org.apache.commons.math3.geometry.euclidean.twod.Line; import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; import org.apache.commons.math3.util.FastMath; import org.apache.commons.math3.util.Precision; /** * Implements Andrew's monotone chain method to generate the convex hull of a finite set of * points in the two-dimensional euclidean space. * <p> * The runtime complexity is O(n log n), with n being the number of input points. If the * point set is already sorted (by x-coordinate), the runtime complexity is O(n). * <p> * The implementation is not sensitive to collinear points on the hull. The parameter * {@code includeCollinearPoints} allows to control the behavior with regard to collinear points. * If {@code true}, all points on the boundary of the hull will be added to the hull vertices, * otherwise only the extreme points will be present. By default, collinear points are not added * as hull vertices. * <p> * The {@code tolerance} parameter (default: 1e-10) is used as epsilon criteria to determine * identical and collinear points. * * @see <a href="http://en.wikibooks.org/wiki/Algorithm_Implementation/Geometry/Convex_hull/Monotone_chain"> * Andrew's monotone chain algorithm (Wikibooks)</a> * @since 3.3 */ public class MonotoneChain extends AbstractConvexHullGenerator2D { /** * Create a new MonotoneChain instance. */ public MonotoneChain() { this(false); } /** * Create a new MonotoneChain instance. * @param includeCollinearPoints whether collinear points shall be added as hull vertices */ public MonotoneChain(final boolean includeCollinearPoints) { super(includeCollinearPoints); } /** * Create a new MonotoneChain instance. * @param includeCollinearPoints whether collinear points shall be added as hull vertices * @param tolerance tolerance below which points are considered identical */ public MonotoneChain(final boolean includeCollinearPoints, final double tolerance) { super(includeCollinearPoints, tolerance); } /** {@inheritDoc} */ @Override public Collection<Vector2D> findHullVertices(final Collection Other Java examples (source code examples)Here is a short list of links related to this Java MonotoneChain.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.