-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
law.cc
98 lines (85 loc) · 3.84 KB
/
law.cc
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*------------------------------------------------------------------------------*/
/* @file law.cc */
/* @details Assign structure for scalar values */
/* @author Paul Isaac's */
/* @date 16.02.2016 */
/* @Copyright © 2016 Paul Isaac's. All rights reserved. */
/*------------------------------------------------------------------------------*/
/* Code snippets used: */
/* Syntax comparison - http://stackoverflow.com & http://cplusplus.com */
/* The class defines a data point and the operations that can be carried out on */
/* it. */
/* Using the hierarchical linking the aim is to develop the application to */
/* relate to real-world physics. This will then ease mapping between simulation,*/
/* emulation and real-world universes. */
#include "law.h"
#include "compositeforceparticle.h"
bool Law::ResetParameters(std::chrono::time_point<Clock> event_time)
{
// If object instantiated without a time specified then add one.
if(time_object_created == std::chrono::time_point<Clock>(std::chrono::nanoseconds::zero()))
{
time_object_created = event_time;
srand((std::chrono::duration_cast<std::chrono::seconds>(TheTimeNow().time_since_epoch()).count()));
}
// If object instantiated without a type specified the set one.
if(law_type < 1)
{
law_type = 1;
}
object_energy = 10 * ((rand() % 30 + 85) / 100);
object_energy_threshold = 2000 * ((rand() % 30 + 85) / 100);
object_size = 1 * ((rand() % 30 + 85) / 100);
switch(law_type)
{
case 0:
{
object_size = 3 * ((rand() % 30 + 85) / 100);
break;
}
case 1:
{
object_size = 2 * ((rand() % 30 + 85) / 100);
break;
}
case 2:
{
object_size = 1 * ((rand() % 30 + 85) / 100);
break;
}
}
return true;
}
unsigned int Law::GetCounter(std::chrono::time_point<Clock> event_time) { std::chrono::time_point<Clock> last_event_time = event_time; return m_Counter; }
void Law::SetCounter(std::chrono::time_point<Clock> event_time, unsigned int val) { m_Counter = val; }
int Law::Update(std::chrono::time_point<Clock> event_time)
{
// If this is the first time that Update is called after object instantiation use the setup parameters.
// object_initialised should then report true and then not be re-run.
if(!object_initialised)
{
object_initialised = ResetParameters(event_time);
}
if(event_time != previous_event_time)
{
// time_dimension_pointer->AdjustCounters(event_time);
duration_since_last_event = std::chrono::duration_cast<std::chrono::nanoseconds>(event_time - previous_event_time).count();
if (duration_since_last_event < 0)
{
duration_since_last_event = 0;
}
if (object_energy < 0)
{
object_energy = 0;
}
if (duration_since_last_event > 0 && object_energy > 0)
{
// Extra programming: Change 0 to correct point address
// Use GetPoint to enable movement across InterneuronSpace to Neuroreceptor
// time_dimension_pointer->AddTemporalAdjustment(event_time, &GetPoint(event_time, 0)->object_energy, object_energy * 0.1, 10000, 1);
// time_dimension_pointer->AddTemporalAdjustment(event_time, &object_energy, 0 - (object_energy * 0.1), 10000, 1);
}
previous_event_time = event_time;
}
return 0;
}