Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/api/Math.py
blob: b514234e28b36810473d9619983ea9018e702e53 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python
# -*- coding: cp1252 -*-

import math

#-------------------------------------------------------------------------------
# toStandardAngle().
# Returns the given angle in the 0-359 range. 
#
# Parameters:
# aAngle: Angle to check.
#
# Returns: The same angle in the 0-359 range.
#-------------------------------------------------------------------------------
def toStandardAngle(aAngle):
    aAngle = aAngle % 360;
    if (aAngle < 0):
        aAngle = aAngle + 360
    return(aAngle)

#-------------------------------------------------------------------------------
# radToDeg().
# Convert the angle given in radians to degrees. 
#
# Parameters:
# aAngle: Angle in radians to be converted.
#
# Returns: The angle in degrees.
#-------------------------------------------------------------------------------
def radToDeg(aAngle):
    return aAngle * 180 / math.pi

#-------------------------------------------------------------------------------
# degToRad().
# Convert the angle given in degrees to radians. 
#
# Parameters:
# aAngle: Angle in degrees to be converted.
#
# Returns: The angle in radians.
#-------------------------------------------------------------------------------
def degToRad(aAngle):
    return aAngle * math.pi / 180