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

org.hipparchus.geometry.euclidean.oned.OrientedPoint Maven / Gradle / Ivy

There is a newer version: 3.1
Show 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.hipparchus.geometry.euclidean.oned;

import org.hipparchus.geometry.Point;
import org.hipparchus.geometry.Vector;
import org.hipparchus.geometry.partitioning.Hyperplane;

/** This class represents a 1D oriented hyperplane.
 * 

An hyperplane in 1D is a simple point, its orientation being a * boolean.

*

Instances of this class are guaranteed to be immutable.

*/ public class OrientedPoint implements Hyperplane { /** Vector location. */ private final Vector1D location; /** Orientation. */ private boolean direct; /** Tolerance below which points are considered to belong to the hyperplane. */ private final double tolerance; /** Simple constructor. * @param location location of the hyperplane * @param direct if true, the plus side of the hyperplane is towards * abscissas greater than {@code location} * @param tolerance tolerance below which points are considered to belong to the hyperplane */ public OrientedPoint(final Vector1D location, final boolean direct, final double tolerance) { this.location = location; this.direct = direct; this.tolerance = tolerance; } /** Copy the instance. *

Since instances are immutable, this method directly returns * the instance.

* @return the instance itself */ @Override public OrientedPoint copySelf() { return this; } /** Get the offset (oriented distance) of a vector. * @param vector vector to check * @return offset of the vector */ public double getOffset(Vector vector) { return getOffset((Point) vector); } /** {@inheritDoc} */ @Override public double getOffset(final Point point) { final double delta = ((Vector1D) point).getX() - location.getX(); return direct ? delta : -delta; } /** Build a region covering the whole hyperplane. *

Since this class represent zero dimension spaces which does * not have lower dimension sub-spaces, this method returns a dummy * implementation of a {@link * org.hipparchus.geometry.partitioning.SubHyperplane SubHyperplane}. * This implementation is only used to allow the {@link * org.hipparchus.geometry.partitioning.SubHyperplane * SubHyperplane} class implementation to work properly, it should * not be used otherwise.

* @return a dummy sub hyperplane */ @Override public SubOrientedPoint wholeHyperplane() { return new SubOrientedPoint(this, null); } /** Build a region covering the whole space. * @return a region containing the instance (really an {@link * IntervalsSet IntervalsSet} instance) */ @Override public IntervalsSet wholeSpace() { return new IntervalsSet(tolerance); } /** {@inheritDoc} */ @Override public boolean sameOrientationAs(final Hyperplane other) { return !(direct ^ ((OrientedPoint) other).direct); } /** {@inheritDoc} */ @Override public Point project(Point point) { return location; } /** {@inheritDoc} */ @Override public double getTolerance() { return tolerance; } /** Get the hyperplane location on the real line. * @return the hyperplane location */ public Vector1D getLocation() { return location; } /** Check if the hyperplane orientation is direct. * @return true if the plus side of the hyperplane is towards * abscissae greater than hyperplane location */ public boolean isDirect() { return direct; } /** Revert the instance. */ public void revertSelf() { direct = !direct; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy