View Javadoc

    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
    19  import org.apache.commons.numbers.core.Precision;
    20
    21  /** Class containing factory methods for constructing {@link CutAngle} instances.
    22   */
    23  public final class CutAngles {
    24
    25      /** Utility class; no instantiation. */
    26      private CutAngles() {
    27      }
    28
    29      /** Create a new instance from the given azimuth and direction.
    30       * @param azimuth azimuth value in radians
    31       * @param positiveFacing if true, the instance's plus side will be oriented to point toward increasing
    32       *      angular values; if false, it will point toward decreasing angular value
    33       * @param precision precision context used to determine floating point equality
    34       * @return a new instance
    35       */
    36      public static CutAngle fromAzimuthAndDirection(final double azimuth, final boolean positiveFacing,
    37              final Precision.DoubleEquivalence precision) {
    38          return fromPointAndDirection(Point1S.of(azimuth), positiveFacing, precision);
    39      }
    40
    41      /** Create a new instance from the given point and direction.
    42       * @param point point representing the location of the hyperplane
    43       * @param positiveFacing if true, the instance's plus side will be oriented to point toward increasing
    44       *      angular values; if false, it will point toward decreasing angular value
    45       * @param precision precision context used to determine floating point equality
    46       * @return a new instance
    47       */
    48      public static CutAngle fromPointAndDirection(final Point1S point, final boolean positiveFacing,
    49              final Precision.DoubleEquivalence precision) {
    50          return new CutAngle(point, positiveFacing, precision);
    51      }
    52
    53      /** Create a new instance at the given azimuth, oriented so that the plus side of the hyperplane points
    54       * toward increasing angular values.
    55       * @param azimuth azimuth value in radians
    56       * @param precision precision precision context used to determine floating point equality
    57       * @return a new instance
    58       */
    59      public static CutAngle createPositiveFacing(final double azimuth, final Precision.DoubleEquivalence precision) {
    60          return createPositiveFacing(Point1S.of(azimuth), precision);
    61      }
    62
    63      /** Create a new instance at the given point, oriented so that the plus side of the hyperplane points
    64       * toward increasing angular values.
    65       * @param point point representing the location of the hyperplane
    66       * @param precision precision precision context used to determine floating point equality
    67       * @return a new instance
    68       */
    69      public static CutAngle createPositiveFacing(final Point1S point, final Precision.DoubleEquivalence precision) {
    70          return fromPointAndDirection(point, true, precision);
    71      }
    72
    73      /** Create a new instance at the given azimuth, oriented so that the plus side of the hyperplane points
    74       * toward decreasing angular values.
    75       * @param azimuth azimuth value in radians
    76       * @param precision precision precision context used to determine floating point equality
    77       * @return a new instance
    78       */
    79      public static CutAngle createNegativeFacing(final double azimuth, final Precision.DoubleEquivalence precision) {
    80          return createNegativeFacing(Point1S.of(azimuth), precision);
    81      }
    82
    83      /** Create a new instance at the given point, oriented so that the plus side of the hyperplane points
    84       * toward decreasing angular values.
    85       * @param point point representing the location of the hyperplane
    86       * @param precision precision precision context used to determine floating point equality
    87       * @return a new instance
    88       */
    89      public static CutAngle createNegativeFacing(final Point1S point, final Precision.DoubleEquivalence precision) {
    90          return fromPointAndDirection(point, false, precision);
    91      }
    92  }