File: unitconv.c

package info (click to toggle)
xshipwars 1.32-5
  • links: PTS
  • area: main
  • in suites: potato
  • size: 17,176 kB
  • ctags: 6,357
  • sloc: ansic: 157,152; makefile: 226; sh: 75
file content (63 lines) | stat: -rw-r--r-- 1,119 bytes parent folder | download
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
                          Unit Conversions

	Functions: 

	double ConvertRUToAU(double x)
	double ConvertRUToSU(double x)

	double ConvertVelocityRUPCToRUPS(double x)
	double ConvertVelocityRUPCToAUPS(double x)

	---

	See ../include/reality.h for official conversion table.

 */

#include <stdio.h>
#include <math.h>

#include "../include/reality.h"



/*
 *	Convert XSW real units to Astronomical units.
 */
double ConvertRUToAU(double x)
{
        return(x * sw_units.ru_to_au);
}

/*
 *	Convert XSW real units to screen units.
 */
double ConvertRUToSU(double x)
{
	return(x * 1000);
}


/*
 *	Convert velocity in XSW real units per cycle (quantom)
 *	XSW real units per second.
 */
double ConvertVelocityRUPCToRUPS(double x)
{
        return(
            x * (1000 / (double)CYCLE_LAPSE_MS)
        );
}

/*
 *      Convert velocity in XSW real units per cycle (quantom)
 *      to Astronomical units per second.
 */
double ConvertVelocityRUPCToAUPS(double x)
{
        return(
            (x * sw_units.ru_to_au) *    /* Convert real units to meters. */
            (1000 / (double)CYCLE_LAPSE_MS)
        );
}