aboutsummaryrefslogtreecommitdiff
path: root/engine/src/desktop/jme3tools/navigation/NumUtil.java
blob: 086fff249dfc3850c1b35c8d777e4fd3128db145 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jme3tools.navigation;

/**
 * Provides various helper methods for number conversions (such as degree to radian
 * conversion, decimal degree to radians etc)
 * @author Benjamin Jakobus, based on JMarine (by Cormac Gebruers and Benjamin
 *          Jakobus)
 * @version 1.0
 * @since 1.0
 */
public class NumUtil {

    /**
     * Rounds a number
     * @param Rval number to be rounded
     * @param Rpl number of decimal places
     * @return rounded number
     * @since 0.1
     */
    public float Round(float Rval, int Rpl) {
        float p = (float) Math.pow(10, Rpl);
        Rval = Rval * p;
        float tmp = Math.round(Rval);
        return (float) tmp / p;
    }
}