Advertisement
Guest User

wheresEdLeed@Yo?

a guest
Sep 19th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.34 KB | None | 0 0
  1. // my sweet sixteen...
  2. //~~~~~ INCLUSIONS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`',
  3. #include<stdio.h>
  4. #include<stdlib.h>
  5. #include<math.h>
  6. #include<time.h>
  7. //definitions
  8. #define PI 3.1415926536
  9. #define INT_MAX 2147483647
  10. #define GRAV 9.81
  11. //local inclusions
  12. #include"colorDefs.h"
  13. #include"structurals.h"
  14. #include"perspective.h"
  15. //~~~~~ MAIN PROGRAM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`',
  16. // Hexanion
  17. //```````````````````````````````````````````````````````````````````````````````````
  18. int main() {
  19. //random seed
  20. randSeed();
  21. //random hexanions
  22. double hexU[16]; makeUnitHex(hexU);
  23. double hexF[16]; foldUnitHex(hexF);
  24. //kill
  25. return 0;
  26. }
  27. //~~~~~ FUNCTIONS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`',
  28. #include"statDefs.h" //statisticl algorithms
  29. #include"arrayDefs.h" //array methods
  30. #include"determinant.h" //classic determinant
  31. #include"linearAlgebra.h" //linear algebraic methods
  32. #include"vectQuat.h" //vectors and quats
  33. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ ~ ~ ~
  34. // ^^^ ABOVE IS OFTEN BLOATED AS CODE IS COPIED UNTIL PURSUED IN ACTIVE MARKET ^^^
  35. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`',
  36. //random octonion
  37. void randOct(double oIn[]) {
  38. int z;
  39. for (z = 0; z < 8; z++) {
  40. oIn[z] = pRand();
  41. }
  42. }
  43. //print octonion
  44. void printOct(double oIn[]) {
  45. int z;
  46. for (z = 0; z < 8; z++) {
  47. printf("%f\n",oIn[z]);
  48. }
  49. printf("\n");
  50. }
  51. //random hexanion
  52. void makeRandHex(double o1[],double o2[],double hex[]) {
  53. int z;
  54. for (z = 0; z < 8; z++) {
  55. int q = z + 8;
  56. hex[z] = o1[z];
  57. hex[q] = o2[z];
  58. }
  59. }
  60. //folded hexanion
  61. void makeFoldHex(double o1[],double o2[],double hex[]) {
  62. hex[0] = sqrt(o1[0]*o2[0]);
  63. int z;
  64. for (z = 1; z < 8; z++) {
  65. int q = z + 7;
  66. hex[z] = o1[z];
  67. hex[q] = o2[z];
  68. }
  69. double derp = pow(o1[0],2) + pow(o2[0],2);
  70. hex[15] = sqrt(derp/2);
  71. }
  72. //print hexanion
  73. void printHex(double hex[]) {
  74. int z;
  75. for (z = 0; z < 16; z++) {
  76. printf("%f\n",hex[z]);
  77. }
  78. printf("\n");
  79. }
  80. //compute radius
  81. void computeRad(double hex[],double *rad) {
  82. double hold = 0.0;
  83. int z;
  84. for (z = 0; z < 16; z++) {
  85. hold += pow(hex[z],2);
  86. }
  87. *rad = sqrt(hold);
  88. }
  89. //unit octonion
  90. void makeUnitOct(double oIn[]) {
  91. double Raxis[7];
  92. int z;
  93. for (z = 0; z < 7; z++) {
  94. Raxis[z] = pRand()-.5;
  95. }
  96. double Rad = 0.0;
  97. for (z = 0; z < 7; z++) {
  98. Rad += pow(Raxis[z],2);
  99. }
  100. Rad = sqrt(Rad);
  101. for (z = 0; z < 7; z++) {
  102. Raxis[z] = Raxis[z]/Rad;
  103. }
  104. double Rangle = (pRand()*2 - 1)*PI;
  105. double theta = Rangle/2;
  106. oIn[0] = cos(theta);
  107. for (z = 0; z < 7; z++) {
  108. oIn[z+1] = sin(theta)*Raxis[z];
  109. }
  110. for (z = 0; z < 8; z++) {
  111. printf("%f\n",oIn[z]);
  112. }
  113. Rad = 0.0;
  114. for (z = 0; z < 8; z++) {
  115. Rad += pow(oIn[z],2);
  116. }
  117. printf("Radius: %f\n",Rad);
  118. }
  119. //unit octonion
  120. void makeUnitHex(double hIn[]) {
  121. printf("Random Unit Hex\n");
  122. double Raxis[15];
  123. int z;
  124. for (z = 0; z < 15; z++) {
  125. Raxis[z] = pRand()-.5;
  126. }
  127. double Rad = 0.0;
  128. for (z = 0; z < 15; z++) {
  129. Rad += pow(Raxis[z],2);
  130. }
  131. Rad = sqrt(Rad);
  132. for (z = 0; z < 15; z++) {
  133. Raxis[z] = Raxis[z]/Rad;
  134. }
  135. double Rangle = (pRand()*2 - 1)*PI;
  136. double theta = Rangle/2;
  137. hIn[0] = cos(theta);
  138. for (z = 0; z < 15; z++) {
  139. hIn[z+1] = sin(theta)*Raxis[z];
  140. }
  141. for (z = 0; z < 16; z++) {
  142. printf("%f\n",hIn[z]);
  143. }
  144. Rad = 0.0;
  145. for (z = 0; z < 16; z++) {
  146. Rad += pow(hIn[z],2);
  147. }
  148. printf("Radius: %f\n\n",Rad);
  149. }
  150. //folded hexanion
  151. void foldUnitHex(double hIn[]) {
  152. double Raxis1[7];
  153. double Raxis2[7];
  154. int z;
  155. for (z = 0; z < 7; z++) {
  156. Raxis1[z] = pRand()-.5;
  157. Raxis2[z] = pRand()-.5;
  158. }
  159. double Rad1 = 0.0;
  160. double Rad2 = 0.0;
  161. for (z = 0; z < 7; z++) {
  162. Rad1 += pow(Raxis1[z],2);
  163. Rad2 += pow(Raxis2[z],2);
  164. }
  165. Rad1 = sqrt(Rad1);
  166. Rad2 = sqrt(Rad2);
  167. for (z = 0; z < 7; z++) {
  168. Raxis1[z] = Raxis1[z]/Rad1;
  169. Raxis2[z] = Raxis2[z]/Rad2;
  170. }
  171. double q1 = 1.0;
  172. double q2 = 1.0;
  173. for (z = 0; z < 7; z++) {
  174. q1 = q1*pow(Raxis1[z],2);
  175. q2 = q2*pow(Raxis2[z],2);
  176. }
  177. double Pres = 1.0/14.0;
  178. q1 = pow(q1,Pres);
  179. q2 = pow(q2,Pres);
  180. double g = sqrt(q1*q2);
  181. double Faxis[15];
  182. for (z = 0; z < 7; z++) {
  183. Faxis[z] = Raxis1[z];
  184. Faxis[z+7] = Raxis2[z];
  185. }
  186. Faxis[14] = g;
  187. double Rad = 0.0;
  188. for (z = 0; z < 15; z++) {
  189. Rad += pow(Faxis[z],2);
  190. }
  191. Rad = sqrt(Rad);
  192. for (z = 0; z < 15; z++) {
  193. Faxis[z] = Faxis[z]/Rad;
  194. }
  195. double Rangle1 = (pRand()*2 - 1)*PI;
  196. double Rangle2 = (pRand()*2 - 1)*PI;
  197. if(Rangle1*Rangle2 < 0.0) {printf("~");}
  198. //make octonion printout
  199. printf("Unit Octonion Pair\n");
  200. double octA[8]; octA[0] = cos(Rangle1/2);
  201. double octB[8]; octB[0] = cos(Rangle2/2);
  202. for (z = 0; z < 7; z++) {
  203. octA[z+1] = sin(Rangle1/2)*Raxis1[z];
  204. octB[z+1] = sin(Rangle2/2)*Raxis2[z];
  205. }
  206. for (z = 0; z < 8; z++) {
  207. printf("%f\t%f\n",octA[z],octB[z]);
  208. }
  209. printf("\n");
  210. double Rsq1 = pow(Rangle1,2);
  211. double Rsq2 = pow(Rangle2,2);
  212. double hold1 = Rsq1*Rsq2;
  213. double hold2 = sqrt(hold1);
  214. double Rangle = sqrt(hold2);
  215. double theta = Rangle/2;
  216. hIn[0] = cos(theta);
  217. printf("Folded Unit Hex\n");
  218. for (z = 0; z < 15; z++) {
  219. hIn[z+1] = sin(theta)*Faxis[z];
  220. }
  221. for (z = 0; z < 16; z++) {
  222. printf("%f\n",hIn[z]);
  223. }
  224. Rad = 0.0;
  225. for (z = 0; z < 16; z++) {
  226. Rad += pow(hIn[z],2);
  227. }
  228. printf("Radius: %f\n",Rad);
  229. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement