Java Degree Convert to degrees2Dist(double degrees, double radius)

Here you can find the source of degrees2Dist(double degrees, double radius)

Description

Converts degrees (1/360th of circumference of a circle) into a distance as measured by the units of the radius.

License

Apache License

Declaration

public static double degrees2Dist(double degrees, double radius) 

Method Source Code

//package com.java2s;
/*/*from  w w  w  .j a v  a2 s .  c  om*/
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class Main {
    public static final double DEGREES_TO_RADIANS = Math.PI / 180;

    /**
     * Converts <code>degrees</code> (1/360th of circumference of a circle) into a
     * distance as measured by the units of the radius.  A spherical earth model
     * is assumed.
     */
    public static double degrees2Dist(double degrees, double radius) {
        return radians2Dist(toRadians(degrees), radius);
    }

    /**
     * Converts <code>radians</code> (multiples of the <code>radius</code>) to
     * distance in the units of the radius (e.g. kilometers).
     */
    public static double radians2Dist(double radians, double radius) {
        return radians * radius;
    }

    /**
     * Same as {@link Math#toRadians(double)} but 3x faster (multiply vs. divide).
     * See CompareRadiansSnippet.java in tests.
     */
    public static double toRadians(double degrees) {
        return degrees * DEGREES_TO_RADIANS;
    }
}

Related

  1. deg2dms(double deg)
  2. degrees(double d)
  3. degreesDiff(double a1, double a2)
  4. degreeSin(double angle)
  5. degreesMinSecToDegrees(String position)
  6. degreesToDecimal(String input)