-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfuckedupfunctions-backup.cs
147 lines (113 loc) · 2.34 KB
/
fuckedupfunctions-backup.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
using System.IO;
using System.Xml;
using System.Net;
private static string RemoveWhiteSpace(string input){
string result = "";
int l=input.Length;
for (int i=0; i<l; ++i){
if (input[i] != ' '){
result += input[i];
}
}
return result;
}
/*
string input=RemoveWhiteSpace(asdnasudnasoidand);
/
string part1 ="http://api.wolframalpha.com/v2/query?input=";
string part2 ="&appid=PG9HJR-4G89HAHLUH&output=xml";
derivativeof2x
string result = part1 + input + part2; */
//get and parse wolfram API for the answer
/*private static string WolframAnswer(var xmlFile){
int l=xmlFile.Length;
for (int i=0; i<l; ++i){
for (int j=1; j<i+1;++j){
for (int k=2; k<j+1;++k){
string newStr = xmlFile[i] + xmlFile[j] + xmlFile[k];
if (newStr == "alt"){
i+=4;
}
}
}
}
string result="";
while (i != '"'){
if (xmlFile[i] == '='){
++i;
} else if (xmlFile[i]==' '){
++i;
} else {
result+=xmlFile[i];
++i;
}
}
return result;
}*/
private static string WolframAnswer(XDocument xmlFile){
int l=xmlFile.Length;
string equation = xmlFile.SelectSingleNode("plaintext").InnerText;
string result="";
while (i != '"'){
if (xmlFile[i] == '='){
++i;
} else if (xmlFile[i]==' '){
++i;
} else {
result+=xmlFile[i];
++i;
}
}
return result;
}
//power conversion testing
private static string WPowConversion(string answer){
int l = answer.Length;
int i=0;
string newAnswer="";
while (i<l){
if ((i+1 < l)&&(answer[i+1] == '^')){
newAnswer = newAnswer + "*Mathf.Pow(" + answer[i] + "," + answer[i+2] + ")";
} else {
newAnswer += answer[i];
}
++i;
}
return newAnswer;
}
//trig conversion
private static string WAnswerConversion(string answer){
int l = answer.Length;
string answer2 = WPowConversion(answer);
string newAnswer="";
string newAnswer2="";
const string sine = Mathf.
int i=0;
int j=0;
while(i<l){
if(answer[i]=='s'){
i+=3;
newAnswer= newAnswer + "Mathf.Sin(" + answer2[i] + ")";
++i;
for (i; i<l; ++i){
newAnswer2[j] = answer2[i];
++j;
}
newAnswer += newAnswer2;
break;
} else if(answer[i]=='c'){
i+=3;
newAnswer= newAnswer + "Mathf.Cos(" + answer2[i] + ")";
++i;
for (i; i<l; ++i){
newAnswer2[j] = answer2[i];
++j;
}
newAnswer += newAnswer2;
break;
} else {
++i;
}
}
return answer2;
}