Guest User

Untitled

a guest
Apr 22nd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Microsoft.Xna.Framework;
  5. using Microsoft.Xna.Framework.Audio;
  6. using Microsoft.Xna.Framework.Content;
  7. using Microsoft.Xna.Framework.GamerServices;
  8. using Microsoft.Xna.Framework.Graphics;
  9. using Microsoft.Xna.Framework.Input;
  10. using Microsoft.Xna.Framework.Media;
  11.  
  12. namespace GravitySimulator
  13. {
  14. class Gravitation
  15. {
  16. static Random Random = new Random();
  17. public Vector3[] positions = new Vector3[3], summovement = new Vector3[3];
  18. public float[,] distance = new float[3, 3], force = new float[4, 4], acceleration = new float[3, 3], velocity = new float[3, 3];
  19. public Vector3[,] dir = new Vector3[3, 3], movement = new Vector3[3, 3];
  20. public double G, mass;
  21.  
  22. public void GenerateVectors()
  23. {
  24. for (int vectors = 0; vectors < positions.Length; vectors++)
  25. {
  26. positions[vectors] = new Vector3(Random.Next(-7, 7), Random.Next(-12, 12), Random.Next(-5, 5));
  27. }
  28. }
  29.  
  30. public void CalculateDistance()
  31. {
  32. for (int j = 0; j < positions.Length; j++)
  33. {
  34. for (int i = 0; i < positions.Length; i++)
  35. {
  36. distance[j, i] = Vector3.Distance(positions[j], positions[i]);
  37. }
  38. }
  39. }
  40.  
  41. public void CalculateForce()
  42. {
  43. G = 6.67 * Math.Pow(10, -11);
  44. mass = 1;
  45. for (int k = 0; k < positions.Length; k++)
  46. {
  47. for (int l = 0; l < positions.Length; l++)
  48. {
  49. force[k, l] = (float)((G * mass * mass) / Math.Pow(distance[k, l], 2));
  50. }
  51. }
  52.  
  53. }
  54.  
  55. public void CalulateAcceleration()
  56. {
  57. for (int m = 0; m < positions.Length; m++)
  58. {
  59. for (int n = 0; n < positions.Length; n++)
  60. {
  61. acceleration[m, n] = (float)(force[m, n] / mass);
  62. }
  63. }
  64. }
  65.  
  66. public void SummariseMovement()
  67. {
  68. for (int a = 0; a < positions.Length; a++)
  69. {
  70. for (int b = 0; b < positions.Length;b++)
  71. {
  72. summovement[a] = movement[a, b];
  73. }
  74. }
  75. }
  76.  
  77. }
  78. }
Add Comment
Please, Sign In to add comment