-
Notifications
You must be signed in to change notification settings - Fork 0
/
ObjectClass.cs
89 lines (80 loc) · 2.5 KB
/
ObjectClass.cs
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
// Copyright 2016 Hugo Perrin, Younes Laaboudi, Maxime Fétiveau, Jules Massin, Olivier Polidori, Seung-Eun Yi
//This file is part of SBT12-GameProjectForAutism.
// SBT12-GameProjectForAutism is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// SBT12-GameProjectForAutism is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with SBT12-GameProjectForAutism. If not, see<http://www.gnu.org/licenses/>.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
public class ObjectClass : MonoBehaviour
{
public List<Vector4> positionList; // list of positions for recording purposes and for equations
protected Vector3 position; // gives the position
public Vector3 GetPosition()
{
return position;
}
public void SetPosition(Vector3 newValue)
{
position = newValue;
}
public void AddPosition(Vector4 Position)
{
if (positionList!= null)
{
positionList.Add(Position);
}
}
public Vector4 GetPosition(int index)
{
if ((index >= 0) & (index < positionList.Count))
{
return positionList[index];
}
else
{
return positionList[positionList.Count-1];
}
}
public List<Vector4> GetList()
{
return positionList;
}
public void CutList(int start, int end)
{
positionList.RemoveRange(start, end);
}
public void InitList()
{
positionList = new List<Vector4>();
}
// Get the position from k*deltaT before
public Vector4 LastPosition(int k)
{
int j = 0;
int i = 0;
int lastIndex = positionList.Count;
float lastTime = GetPosition(lastIndex).w;
while (j!=k)
{
if (GetPosition(lastIndex-1-i).w==lastTime)
{
i = i + 1;
}
else
{
j = j + 1;
lastTime = GetPosition(lastIndex - 1 - i).w;
}
}
return GetPosition(lastIndex - 1 - i);
}
}