CutAngles.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.spherical.oned;

  18. import org.apache.commons.numbers.core.Precision;

  19. /** Class containing factory methods for constructing {@link CutAngle} instances.
  20.  */
  21. public final class CutAngles {

  22.     /** Utility class; no instantiation. */
  23.     private CutAngles() {
  24.     }

  25.     /** Create a new instance from the given azimuth and direction.
  26.      * @param azimuth azimuth value in radians
  27.      * @param positiveFacing if true, the instance's plus side will be oriented to point toward increasing
  28.      *      angular values; if false, it will point toward decreasing angular value
  29.      * @param precision precision context used to determine floating point equality
  30.      * @return a new instance
  31.      */
  32.     public static CutAngle fromAzimuthAndDirection(final double azimuth, final boolean positiveFacing,
  33.             final Precision.DoubleEquivalence precision) {
  34.         return fromPointAndDirection(Point1S.of(azimuth), positiveFacing, precision);
  35.     }

  36.     /** Create a new instance from the given point and direction.
  37.      * @param point point representing the location of the hyperplane
  38.      * @param positiveFacing if true, the instance's plus side will be oriented to point toward increasing
  39.      *      angular values; if false, it will point toward decreasing angular value
  40.      * @param precision precision context used to determine floating point equality
  41.      * @return a new instance
  42.      */
  43.     public static CutAngle fromPointAndDirection(final Point1S point, final boolean positiveFacing,
  44.             final Precision.DoubleEquivalence precision) {
  45.         return new CutAngle(point, positiveFacing, precision);
  46.     }

  47.     /** Create a new instance at the given azimuth, oriented so that the plus side of the hyperplane points
  48.      * toward increasing angular values.
  49.      * @param azimuth azimuth value in radians
  50.      * @param precision precision precision context used to determine floating point equality
  51.      * @return a new instance
  52.      */
  53.     public static CutAngle createPositiveFacing(final double azimuth, final Precision.DoubleEquivalence precision) {
  54.         return createPositiveFacing(Point1S.of(azimuth), precision);
  55.     }

  56.     /** Create a new instance at the given point, oriented so that the plus side of the hyperplane points
  57.      * toward increasing angular values.
  58.      * @param point point representing the location of the hyperplane
  59.      * @param precision precision precision context used to determine floating point equality
  60.      * @return a new instance
  61.      */
  62.     public static CutAngle createPositiveFacing(final Point1S point, final Precision.DoubleEquivalence precision) {
  63.         return fromPointAndDirection(point, true, precision);
  64.     }

  65.     /** Create a new instance at the given azimuth, oriented so that the plus side of the hyperplane points
  66.      * toward decreasing angular values.
  67.      * @param azimuth azimuth value in radians
  68.      * @param precision precision precision context used to determine floating point equality
  69.      * @return a new instance
  70.      */
  71.     public static CutAngle createNegativeFacing(final double azimuth, final Precision.DoubleEquivalence precision) {
  72.         return createNegativeFacing(Point1S.of(azimuth), precision);
  73.     }

  74.     /** Create a new instance at the given point, oriented so that the plus side of the hyperplane points
  75.      * toward decreasing angular values.
  76.      * @param point point representing the location of the hyperplane
  77.      * @param precision precision precision context used to determine floating point equality
  78.      * @return a new instance
  79.      */
  80.     public static CutAngle createNegativeFacing(final Point1S point, final Precision.DoubleEquivalence precision) {
  81.         return fromPointAndDirection(point, false, precision);
  82.     }
  83. }