001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.geometry.spherical.oned;
018
019import org.apache.commons.numbers.core.Precision;
020
021/** Class containing factory methods for constructing {@link CutAngle} instances.
022 */
023public final class CutAngles {
024
025    /** Utility class; no instantiation. */
026    private CutAngles() {
027    }
028
029    /** Create a new instance from the given azimuth and direction.
030     * @param azimuth azimuth value in radians
031     * @param positiveFacing if true, the instance's plus side will be oriented to point toward increasing
032     *      angular values; if false, it will point toward decreasing angular value
033     * @param precision precision context used to determine floating point equality
034     * @return a new instance
035     */
036    public static CutAngle fromAzimuthAndDirection(final double azimuth, final boolean positiveFacing,
037            final Precision.DoubleEquivalence precision) {
038        return fromPointAndDirection(Point1S.of(azimuth), positiveFacing, precision);
039    }
040
041    /** Create a new instance from the given point and direction.
042     * @param point point representing the location of the hyperplane
043     * @param positiveFacing if true, the instance's plus side will be oriented to point toward increasing
044     *      angular values; if false, it will point toward decreasing angular value
045     * @param precision precision context used to determine floating point equality
046     * @return a new instance
047     */
048    public static CutAngle fromPointAndDirection(final Point1S point, final boolean positiveFacing,
049            final Precision.DoubleEquivalence precision) {
050        return new CutAngle(point, positiveFacing, precision);
051    }
052
053    /** Create a new instance at the given azimuth, oriented so that the plus side of the hyperplane points
054     * toward increasing angular values.
055     * @param azimuth azimuth value in radians
056     * @param precision precision precision context used to determine floating point equality
057     * @return a new instance
058     */
059    public static CutAngle createPositiveFacing(final double azimuth, final Precision.DoubleEquivalence precision) {
060        return createPositiveFacing(Point1S.of(azimuth), precision);
061    }
062
063    /** Create a new instance at the given point, oriented so that the plus side of the hyperplane points
064     * toward increasing angular values.
065     * @param point point representing the location of the hyperplane
066     * @param precision precision precision context used to determine floating point equality
067     * @return a new instance
068     */
069    public static CutAngle createPositiveFacing(final Point1S point, final Precision.DoubleEquivalence precision) {
070        return fromPointAndDirection(point, true, precision);
071    }
072
073    /** Create a new instance at the given azimuth, oriented so that the plus side of the hyperplane points
074     * toward decreasing angular values.
075     * @param azimuth azimuth value in radians
076     * @param precision precision precision context used to determine floating point equality
077     * @return a new instance
078     */
079    public static CutAngle createNegativeFacing(final double azimuth, final Precision.DoubleEquivalence precision) {
080        return createNegativeFacing(Point1S.of(azimuth), precision);
081    }
082
083    /** Create a new instance at the given point, oriented so that the plus side of the hyperplane points
084     * toward decreasing angular values.
085     * @param point point representing the location of the hyperplane
086     * @param precision precision precision context used to determine floating point equality
087     * @return a new instance
088     */
089    public static CutAngle createNegativeFacing(final Point1S point, final Precision.DoubleEquivalence precision) {
090        return fromPointAndDirection(point, false, precision);
091    }
092}