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.math3.geometry.spherical.oned;
018
019import org.apache.commons.math3.geometry.partitioning.AbstractSubHyperplane;
020import org.apache.commons.math3.geometry.partitioning.Hyperplane;
021import org.apache.commons.math3.geometry.partitioning.Region;
022
023/** This class represents sub-hyperplane for {@link LimitAngle}.
024 * <p>Instances of this class are guaranteed to be immutable.</p>
025 * @since 3.3
026 */
027public class SubLimitAngle extends AbstractSubHyperplane<Sphere1D, Sphere1D> {
028
029    /** Simple constructor.
030     * @param hyperplane underlying hyperplane
031     * @param remainingRegion remaining region of the hyperplane
032     */
033    public SubLimitAngle(final Hyperplane<Sphere1D> hyperplane,
034                         final Region<Sphere1D> remainingRegion) {
035        super(hyperplane, remainingRegion);
036    }
037
038    /** {@inheritDoc} */
039    @Override
040    public double getSize() {
041        return 0;
042    }
043
044    /** {@inheritDoc} */
045    @Override
046    public boolean isEmpty() {
047        return false;
048    }
049
050    /** {@inheritDoc} */
051    @Override
052    protected AbstractSubHyperplane<Sphere1D, Sphere1D> buildNew(final Hyperplane<Sphere1D> hyperplane,
053                                                                 final Region<Sphere1D> remainingRegion) {
054        return new SubLimitAngle(hyperplane, remainingRegion);
055    }
056
057    /** {@inheritDoc} */
058    @Override
059    public SplitSubHyperplane<Sphere1D> split(final Hyperplane<Sphere1D> hyperplane) {
060        final double global = hyperplane.getOffset(((LimitAngle) getHyperplane()).getLocation());
061        return (global < -1.0e-10) ?
062                                    new SplitSubHyperplane<Sphere1D>(null, this) :
063                                    new SplitSubHyperplane<Sphere1D>(this, null);
064    }
065
066}