aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ode-0.9/GIMPACT/src/gim_math.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/ode-0.9/GIMPACT/src/gim_math.cpp')
-rw-r--r--libraries/ode-0.9/GIMPACT/src/gim_math.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/libraries/ode-0.9/GIMPACT/src/gim_math.cpp b/libraries/ode-0.9/GIMPACT/src/gim_math.cpp
new file mode 100644
index 0000000..18efb2c
--- /dev/null
+++ b/libraries/ode-0.9/GIMPACT/src/gim_math.cpp
@@ -0,0 +1,60 @@
1/*
2-----------------------------------------------------------------------------
3This source file is part of GIMPACT Library.
4
5For the latest info, see http://gimpact.sourceforge.net/
6
7Copyright (c) 2006 Francisco Leon. C.C. 80087371.
8email: projectileman@yahoo.com
9
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of EITHER:
12 (1) The GNU Lesser General Public License as published by the Free
13 Software Foundation; either version 2.1 of the License, or (at
14 your option) any later version. The text of the GNU Lesser
15 General Public License is included with this library in the
16 file GIMPACT-LICENSE-LGPL.TXT.
17 (2) The BSD-style license that is included with this library in
18 the file GIMPACT-LICENSE-BSD.TXT.
19
20 This library is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
23 GIMPACT-LICENSE-LGPL.TXT and GIMPACT-LICENSE-BSD.TXT for more details.
24
25-----------------------------------------------------------------------------
26*/
27
28
29#include "GIMPACT/gim_math.h"
30#include "stdlib.h"
31#include "time.h"
32
33
34GREAL gim_inv_sqrt(GREAL f)
35{
36 GREAL r;
37 GIM_INV_SQRT(f,r);
38 return r;
39}
40
41GREAL gim_sqrt(GREAL f)
42{
43 GREAL r;
44 GIM_SQRT(f,r);
45 return r;
46}
47
48//!Initializes mathematical functions
49void gim_init_math()
50{
51 srand( static_cast< unsigned int >( time( 0 ) ) );
52}
53
54//! Generates an unit random
55GREAL gim_unit_random()
56{
57 GREAL rn = static_cast< GREAL >( rand() );
58 rn/=(GREAL)RAND_MAX;
59 return rn;
60}