jongyon7192p

Pendulum Map Generator Pseudocode

Nov 11th, 2018
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.76 KB | None | 0 0
  1. t13=0 //Step Index: how much time a pendulum takes to move from an amplitude to the center, in other words, one-fourth of a period.
  2. t42=0 //Each integer n time from amplitude to center boosts the pendulum's amplitude
  3. and is significant in reaching a new set of amplitudes. These amplitudes of quarter period, n,
  4. are called Rail Amplitudes, as in the map, they lie on the rail of what looks like a ladder.
  5. //Therefore, integer quarter periods are called Step Indexes cuz they sandwich a series of non-rail amplitudes,
  6. which we call a step. The step index gives these series of amplitudes a designation.
  7.  
  8. public static void static Main whatever{
  9. for(1~n){ //there are infinite steps so we want only the first n.
  10. a13=6.5*t13*(t13+1) //derive Rail Amplitudes from the pendulum's Quarter Periods
  11. a42=215*t42*(t42+1)
  12.  
  13. if (a13<a42){ //we choose to analyze the smaller Rail Amplitude.
  14. //We don't read a42 right after since a13 might still be larger
  15. print("rail13")
  16. readStep(a13,t13,42)
  17. t13++
  18. }else if(a13>a42){ //this case is a bit less likely to occur, as 42>13. After a42, a13 is always larger.
  19. print("rail42")
  20. readStep(a42,t42,13)
  21. t42++
  22. print("rail13")
  23. readStep(a13,t13,42)
  24. t13++
  25. }else if (a13==a42){ //this case is BY FAR the least likely to occur. just read both steps.
  26. print("Intersect!")
  27. readStep(a13,t13,42)
  28. t13++
  29. print("Intersect!")
  30. readStep(a42,t42,13)
  31. t42++
  32. }
  33. print(stepIndex, amplitude, length, stepType, and connect \n)
  34. also, store all this data in an array or something. I wanna paste it in a spreadsheet.
  35.  
  36. At the end of this for loop, I should've stored the unused amplitude so we don't recalculate it again EVERY for loop,
  37. but I don't know how to do that.
  38. }
  39.  
  40. next, drawTheDamnMap()
  41.  
  42. User can ask for several things now.
  43. 1. Output the list of steps. Ask to filter certain stepTypes or an entire rail.
  44. 2. Draw graph of step vs stepLength
  45. 3. Accept a step index and draw a graph of swing index vs amplitude within that step.
  46. }
  47.  
  48. readStep(amp,stepIndex,startAccel) { //find a step's length, type, and what rail number it connects to.
  49. /*Fist, if this amp is equal to ANY connect values in the array
  50. (check given index from biggest array amp's connect to the 1st amp smaller than this amp),
  51. then skip the entire readStep sequence. Connect = that array amp.
  52. The stepLength and stepType is identical to that step.*/
  53.  
  54. if(this amp equals a connect value in the array){
  55. skip this whole thing and do what that comment says.
  56. }else{
  57.  
  58. startAmp=amp
  59. length=0
  60. prevAmp=0
  61. accel=startAccel
  62. nonIntegerT=sqrt(2*amp/accel+.25)-.5
  63. while (amp!=prevAmp || nonIntegerT%1 != 0){ //this loop swings the pendulum til it find the end of the given step
  64. prevAmp=amp;
  65. amp=accel*ceil(nonIntegerT)^2-amp;
  66. swapAccel(13->42 or 42->13)
  67. nonIntegerT=sqrt(2*amp/accel+.25)-.5
  68. length++
  69. }
  70. stepType=null; //The Type is purely defined by where the step connects to.
  71. connect=null; //this is what step index this step connects to. It normally connects to its startAmp,
  72. in which case, the step is symmetric. But sometimes it goes somewhere random.
  73. Which rail it connects to is simply if the length is even or odd, so the data is considered stored there.
  74.  
  75. if(amp==prevAmp){
  76. stepType=normal
  77. connect=stepIndex
  78. length*=2
  79. }else if(length%2){
  80. stepType=13To42
  81. connect=nonIntegerT
  82. }else{
  83. stepType=StepToStep
  84. connect=nonIntegerT
  85. }
  86. }
  87. return(length, stepType, connect)
  88. }
Advertisement
Add Comment
Please, Sign In to add comment