Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Microsoft.Xna.Framework;
- using Microsoft.Xna.Framework.Audio;
- using Microsoft.Xna.Framework.Content;
- using Microsoft.Xna.Framework.GamerServices;
- using Microsoft.Xna.Framework.Graphics;
- using Microsoft.Xna.Framework.Input;
- using Microsoft.Xna.Framework.Media;
- namespace GravitySimulator
- {
- class Gravitation
- {
- static Random Random = new Random();
- public Vector3[] positions = new Vector3[3], summovement = new Vector3[3];
- public float[,] distance = new float[3, 3], force = new float[4, 4], acceleration = new float[3, 3], velocity = new float[3, 3];
- public Vector3[,] dir = new Vector3[3, 3], movement = new Vector3[3, 3];
- public double G, mass;
- public void GenerateVectors()
- {
- for (int vectors = 0; vectors < positions.Length; vectors++)
- {
- positions[vectors] = new Vector3(Random.Next(-7, 7), Random.Next(-12, 12), Random.Next(-5, 5));
- }
- }
- public void CalculateDistance()
- {
- for (int j = 0; j < positions.Length; j++)
- {
- for (int i = 0; i < positions.Length; i++)
- {
- distance[j, i] = Vector3.Distance(positions[j], positions[i]);
- }
- }
- }
- public void CalculateForce()
- {
- G = 6.67 * Math.Pow(10, -11);
- mass = 1;
- for (int k = 0; k < positions.Length; k++)
- {
- for (int l = 0; l < positions.Length; l++)
- {
- force[k, l] = (float)((G * mass * mass) / Math.Pow(distance[k, l], 2));
- }
- }
- }
- public void CalulateAcceleration()
- {
- for (int m = 0; m < positions.Length; m++)
- {
- for (int n = 0; n < positions.Length; n++)
- {
- acceleration[m, n] = (float)(force[m, n] / mass);
- }
- }
- }
- public void SummariseMovement()
- {
- for (int a = 0; a < positions.Length; a++)
- {
- for (int b = 0; b < positions.Length;b++)
- {
- summovement[a] = movement[a, b];
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment