This repository was archived by the owner on Dec 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTest_Dimensions_PhysicsValue.cpp
75 lines (54 loc) · 2.21 KB
/
Test_Dimensions_PhysicsValue.cpp
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
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright (c) Zhirnov Andrey. For more information see 'LICENSE.txt'
#include "CoreTests/Physics/Common.h"
using namespace GXPhysics;
static void TestPhysicsValue ()
{
typedef DefaultPhysicsValues< float >::Seconds Sec;
typedef DefaultPhysicsValues< float >::Meters M;
typedef DefaultPhysicsValues< float >::Millimeters MM;
typedef DefaultPhysicsValues< float >::Kilograms Kg;
typedef DefaultPhysicsValues< float >::MetersPerSeconds Vel;
typedef DefaultPhysicsValues< float >::MetersPerSquareSeconds Accel;
typedef DefaultPhysicsValues< float >::Newtons N;
typedef DefaultPhysicsValues< float >::GConstant G;
typedef DefaultPhysicsValues< float >::SolarMass SM;
typedef DefaultPhysicsValues< float >::AstronomicalUnits AU;
typedef DefaultPhysicsValues< float >::Daltons Da;
typedef DefaultPhysicsValues< float >::Grams Gr;
typedef DefaultPhysicsValues< float >::Moles Mol;
typedef DefaultPhysicsValues< float >::GramsPerMoles MolMass;
typedef PhysicsValueVec< M, 1 > M1;
typedef PhysicsValueVec< M, 3 > M3;
typedef PhysicsValueVec< MM, 3 > MM3;
typedef PhysicsValueVec< Vel, 3 > Vel3;
const M distance = M(10.0f);
const Sec time = Sec(2.0f);
const Kg mass = Kg(8.0f);
const MM dist = M(1.0f);
const Sec y = DefaultPhysicsValues< float >::Years(1.0f);
Vel velocity = distance / time;
Sec time2 = distance / velocity;
//Sec time3 = velocity / distance; // error
Accel acceleration = velocity / time;
//Accel accel2 = distance / time.Pow< -2 >(); // error
N force = acceleration * mass;
M length = velocity * time + acceleration * time.Square() * 0.5f;
float f = length / length;
MM len_mm = length.To< MM >();
Vel3 v3 = MM3( M3( M(1.0f), M(2.0f), M(3.0f) ) ) / Sec( 0.5f );
Vel v1 = v3.Length();
auto m = M1( M(1.0f) ).Volume();
GX_UNUSED( f, m, len_mm );
/*WARNING( m.ToDebugString().cstr() );
WARNING( time2.ToString().cstr() );
WARNING( velocity.ToString().cstr() );
WARNING( acceleration.ToString().cstr() );
WARNING( force.ToString().cstr() );
WARNING( dist.ToString().cstr() );
auto n = G(1) * (SM(1) * SM(2)) / AU(1).Square();
WARNING( n.ToDebugString().cstr() );*/
}
extern void Test_Dimensions_PhysicsValue ()
{
TestPhysicsValue();
}