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 */
017
018package org.apache.commons.math3.geometry.euclidean.threed;
019
020import java.io.Serializable;
021
022import org.apache.commons.math3.geometry.Space;
023import org.apache.commons.math3.geometry.euclidean.twod.Euclidean2D;
024
025/**
026 * This class implements a three-dimensional space.
027 * @since 3.0
028 */
029public class Euclidean3D implements Serializable, Space {
030
031    /** Serializable version identifier. */
032    private static final long serialVersionUID = 6249091865814886817L;
033
034    /** Private constructor for the singleton.
035     */
036    private Euclidean3D() {
037    }
038
039    /** Get the unique instance.
040     * @return the unique instance
041     */
042    public static Euclidean3D getInstance() {
043        return LazyHolder.INSTANCE;
044    }
045
046    /** {@inheritDoc} */
047    public int getDimension() {
048        return 3;
049    }
050
051    /** {@inheritDoc} */
052    public Euclidean2D getSubSpace() {
053        return Euclidean2D.getInstance();
054    }
055
056    // CHECKSTYLE: stop HideUtilityClassConstructor
057    /** Holder for the instance.
058     * <p>We use here the Initialization On Demand Holder Idiom.</p>
059     */
060    private static class LazyHolder {
061        /** Cached field instance. */
062        private static final Euclidean3D INSTANCE = new Euclidean3D();
063    }
064    // CHECKSTYLE: resume HideUtilityClassConstructor
065
066    /** Handle deserialization of the singleton.
067     * @return the singleton instance
068     */
069    private Object readResolve() {
070        // return the singleton instance
071        return LazyHolder.INSTANCE;
072    }
073
074}