commit f3e0c88a2ee11d5ac959969ed5bc2868516912d3
parent a5b682fe7abe842f32e2025245ca4281869499ba
Author: Mikolaj Lenczewski <33129490+EnderRifter@users.noreply.github.com>
Date: Mon, 1 Jul 2019 13:26:40 +0100
Moved data types to separate folder. Also fixed rotation bug. Rotation is enabled, as is most of the interactivity.
Diffstat:
13 files changed, 1483 insertions(+), 1046 deletions(-)
diff --git a/StarSim/StarSim/Program.cs b/StarSim/StarSim/Program.cs
@@ -15,6 +15,11 @@ namespace StarSim
internal class Program
{
/// <summary>
+ /// Holds all the <see cref="Body"/> instances that should be simulated.
+ /// </summary>
+ private static readonly Body[] bodies;
+
+ /// <summary>
/// The renderer used to display the <see cref="Body"/> instances on the screen.
/// </summary>
private static readonly Drawer bodyDrawer;
@@ -35,11 +40,6 @@ namespace StarSim
private static readonly RenderWindow window;
/// <summary>
- /// Holds all the <see cref="Body"/> instances that should be simulated.
- /// </summary>
- private static Body[] bodies;
-
- /// <summary>
/// Maps a <see cref="Body"/> to the <see cref="CircleShape"/> that represents it, and is drawn to the
/// screen at the <see cref="Body"/>s position.
/// </summary>
@@ -80,6 +80,8 @@ namespace StarSim
/// <param name="eventArgs">The <see cref="KeyEventArgs"/> associated with the key press.</param>
private static void HandleKeyPressed(object sender, KeyEventArgs eventArgs)
{
+ string msg = "";
+
switch (eventArgs.Code)
{
case Keyboard.Key.Space:
@@ -88,28 +90,123 @@ namespace StarSim
break;
case Keyboard.Key.W:
- case Keyboard.Key.Up:
// rotate the view north
+ bodyDrawer.Rotate(RotationDirection.North, Constants.EulerRotationStep);
+ msg = $"Rotated by {Constants.EulerRotationStep} anticlockwise in the x axis. " +
+ $"View Rotation: ({bodyDrawer.XAngle},{bodyDrawer.YAngle},{bodyDrawer.ZAngle})";
break;
case Keyboard.Key.A:
- case Keyboard.Key.Left:
// rotate the view west
+ bodyDrawer.Rotate(RotationDirection.West, Constants.EulerRotationStep);
+ msg = $"Rotated by {Constants.EulerRotationStep} clockwise in the y axis. " +
+ $"View Rotation: ({bodyDrawer.XAngle},{bodyDrawer.YAngle},{bodyDrawer.ZAngle})";
break;
case Keyboard.Key.S:
- case Keyboard.Key.Down:
// rotate the view south
+ bodyDrawer.Rotate(RotationDirection.South, Constants.EulerRotationStep);
+ msg = $"Rotated by {Constants.EulerRotationStep} clockwise in the x axis. " +
+ $"View Rotation: ({bodyDrawer.XAngle},{bodyDrawer.YAngle},{bodyDrawer.ZAngle})";
break;
case Keyboard.Key.D:
- case Keyboard.Key.Right:
// rotate the view east
+ bodyDrawer.Rotate(RotationDirection.East, Constants.EulerRotationStep);
+ msg = $"Rotated by {Constants.EulerRotationStep} anticlockwise in the y axis. " +
+ $"View Rotation: ({bodyDrawer.XAngle},{bodyDrawer.YAngle},{bodyDrawer.ZAngle})";
+ break;
+
+ case Keyboard.Key.Q:
+ // rotate the view anti-clockwise
+ bodyDrawer.Rotate(RotationDirection.Anticlockwise, Constants.EulerRotationStep);
+ msg = $"Rotated by {Constants.EulerRotationStep} anticlockwise in the z axis. " +
+ $"View Rotation: ({bodyDrawer.XAngle},{bodyDrawer.YAngle},{bodyDrawer.ZAngle})";
+ break;
+
+ case Keyboard.Key.E:
+ // rotate the view clockwise
+ bodyDrawer.Rotate(RotationDirection.Clockwise, Constants.EulerRotationStep);
+ msg = $"Rotated by {Constants.EulerRotationStep} anticlockwise in the z axis. " +
+ $"View Rotation: ({bodyDrawer.XAngle},{bodyDrawer.YAngle},{bodyDrawer.ZAngle})";
break;
default:
break;
}
+
+ if (!msg.Equals(""))
+ {
+ Console.WriteLine(msg);
+ }
+ }
+
+ /// <summary>
+ /// Handles key releases.
+ /// </summary>
+ /// <param name="sender">The <see cref="Window"/> that sent the event.</param>
+ /// <param name="eventArgs">The <see cref="KeyEventArgs"/> associated with the key press.</param>
+ private static void HandleKeyReleased(object sender, KeyEventArgs eventArgs)
+ {
+ string msg = "";
+
+ switch (eventArgs.Code)
+ {
+ case Keyboard.Key.Space:
+ // toggle the paused state
+ IsSimulationPaused = !IsSimulationPaused;
+ break;
+
+ case Keyboard.Key.W:
+ // rotate the view north
+ bodyDrawer.Rotate(RotationDirection.North, Constants.EulerRotationStep);
+ msg = $"Rotated by {Constants.EulerRotationStep} anticlockwise in the x axis. " +
+ $"View Rotation: ({bodyDrawer.XAngle},{bodyDrawer.YAngle},{bodyDrawer.ZAngle})";
+ break;
+
+ case Keyboard.Key.A:
+ // rotate the view west
+ bodyDrawer.Rotate(RotationDirection.West, Constants.EulerRotationStep);
+ msg = $"Rotated by {Constants.EulerRotationStep} clockwise in the y axis. " +
+ $"View Rotation: ({bodyDrawer.XAngle},{bodyDrawer.YAngle},{bodyDrawer.ZAngle})";
+ break;
+
+ case Keyboard.Key.S:
+ // rotate the view south
+ bodyDrawer.Rotate(RotationDirection.South, Constants.EulerRotationStep);
+ msg = $"Rotated by {Constants.EulerRotationStep} clockwise in the x axis. " +
+ $"View Rotation: ({bodyDrawer.XAngle},{bodyDrawer.YAngle},{bodyDrawer.ZAngle})";
+ break;
+
+ case Keyboard.Key.D:
+ // rotate the view east
+ bodyDrawer.Rotate(RotationDirection.East, Constants.EulerRotationStep);
+ msg = $"Rotated by {Constants.EulerRotationStep} anticlockwise in the y axis. " +
+ $"View Rotation: ({bodyDrawer.XAngle},{bodyDrawer.YAngle},{bodyDrawer.ZAngle})";
+ break;
+
+ case Keyboard.Key.Q:
+ // rotate the view anti-clockwise
+ bodyDrawer.Rotate(RotationDirection.Anticlockwise, Constants.EulerRotationStep);
+ msg = $"Rotated by {Constants.EulerRotationStep} anticlockwise in the z axis. " +
+ $"View Rotation: ({bodyDrawer.XAngle},{bodyDrawer.YAngle},{bodyDrawer.ZAngle})";
+ break;
+
+ case Keyboard.Key.E:
+ // rotate the view clockwise
+ bodyDrawer.Rotate(RotationDirection.Clockwise, Constants.EulerRotationStep);
+ msg = $"Rotated by {Constants.EulerRotationStep} anticlockwise in the z axis. " +
+ $"View Rotation: ({bodyDrawer.XAngle},{bodyDrawer.YAngle},{bodyDrawer.ZAngle})";
+ break;
+
+ default:
+ break;
+ }
+
+ if (!msg.Equals(""))
+ {
+ Console.WriteLine(msg);
+ }
}
/// <summary>
@@ -151,11 +248,11 @@ namespace StarSim
{
if (eventArgs.Delta > 0)
{
- bodyDrawer.Scale(1.1f);
+ bodyDrawer.Scale(1 + Constants.ZoomStep);
}
else if (eventArgs.Delta < 0)
{
- bodyDrawer.Scale(0.9f);
+ bodyDrawer.Scale(1 - Constants.ZoomStep);
}
}
@@ -179,6 +276,7 @@ namespace StarSim
// we apply event handlers to allow for interactivity inside the window
window.KeyPressed += HandleKeyPressed;
+ //window.KeyReleased += HandleKeyReleased;
window.MouseButtonPressed += HandleMousePressed;
window.MouseButtonReleased += HandleMouseReleased;
//window.MouseMoved += HandleMouseMoved;
diff --git a/StarSim/StarSimLib/Constants.cs b/StarSim/StarSimLib/Constants.cs
@@ -10,7 +10,7 @@ namespace StarSimLib
/// <summary>
/// The amount of bodies that are rendered by default.
/// </summary>
- public const int BodyCount = 20;
+ public const int BodyCount = 3;
/// <summary>
/// The mass of the central body, if it is included.
@@ -18,9 +18,14 @@ namespace StarSimLib
public const double CentralBodyMass = SolarMass * 1e6;
/// <summary>
+ /// The amount of degrees by which the view will be rotated in any given direction.
+ /// </summary>
+ public const double EulerRotationStep = 5;
+
+ /// <summary>
/// The frame rate limit for the program.
/// </summary>
- public const uint FrameRate = 60;
+ public const uint FrameRate = 144;
/// <summary>
/// The gravitational constant (m^3 kg^-1 s^-2).
@@ -58,13 +63,13 @@ namespace StarSimLib
public const double TimeStep = SecondsPerTick * (SimulationRate / (float)FrameRate) * SimulationRate;
/// <summary>
- /// Factor by which to multiply the position of <see cref="Body"/>s to scale them to the screen for displaying.
+ /// The maximum radius within which <see cref="Body"/>s will be placed (1e18f).
/// </summary>
- public const double UniverseScalingFactor = 2500 / UniverseSize;
+ public const double UniverseSize = 1e18f;
/// <summary>
- /// The maximum radius within which <see cref="Body"/>s will be placed (1e18f).
+ /// The amount by which the zoom level will be increased or decreased.
/// </summary>
- public const double UniverseSize = 1e18f;
+ public const double ZoomStep = 0.05;
}
}
\ No newline at end of file
diff --git a/StarSim/StarSimLib/Data Structures/Matrix4x4.cs b/StarSim/StarSimLib/Data Structures/Matrix4x4.cs
@@ -0,0 +1,180 @@
+using System;
+
+namespace StarSimLib.Data_Structures
+{
+ /// <summary>
+ /// A 4-by-4 matrix of <see cref="double"/> values.
+ /// </summary>
+ public struct Matrix4x4
+ {
+ /// <summary>
+ /// The internal matrix representation.
+ /// </summary>
+ private readonly double[][] matrix;
+
+ /// <summary>
+ /// The default <see cref="MatrixValueGeneratorDelegate"/> to use when constructing a <see cref="Matrix4x4"/>
+ /// from a given 2D <see cref="double"/> array. Simply copies over the values from the source matrix to the
+ /// output matrix. Should the source matrix contain null fields, a 0 will be placed at the relevant field in
+ /// the target matrix.
+ /// </summary>
+ public static readonly MatrixValueGeneratorDelegate CopyMatrixValuesGeneratorDelegate =
+ (sourceMatrix, i, j) => sourceMatrix?[i]?[j] ?? 0;
+
+ /// <summary>
+ /// Initialises a new instance of the <see cref="Matrix4x4"/> struct.
+ /// </summary>
+ /// <param name="defaultValue">The value to which to initialise all fields in the matrix.</param>
+ public Matrix4x4(double defaultValue) : this(null, (sourceMatrix, i, j) => defaultValue)
+ {
+ }
+
+ /// <summary>
+ /// Initialises a new instance of the <see cref="Matrix4x4"/> struct.
+ /// </summary>
+ /// <param name="sourceMatrix">The source matrix from which to copy over values.</param>
+ public Matrix4x4(double[][] sourceMatrix) : this(sourceMatrix, CopyMatrixValuesGeneratorDelegate)
+ {
+ }
+
+ /// <summary>
+ /// Initialises a new instance of the <see cref="Matrix4x4"/> struct.
+ /// </summary>
+ /// <param name="sourceMatrix">The source matrix from which to copy over values.</param>
+ public Matrix4x4(Matrix4x4 sourceMatrix) : this(sourceMatrix, CopyMatrixValuesGeneratorDelegate)
+ {
+ }
+
+ /// <summary>
+ /// Initialises a new instance of the <see cref="Matrix4x4"/> struct.
+ /// </summary>
+ /// <param name="sourceMatrix">The source matrix.</param>
+ /// <param name="valueGenerator">
+ /// The <see cref="MatrixValueGeneratorDelegate"/> to use to generate new matrix values. Can use the source matrix
+ /// or can ignore it.
+ /// </param>
+ public Matrix4x4(double[][] sourceMatrix, MatrixValueGeneratorDelegate valueGenerator)
+ {
+ // construct the columns
+ matrix = new double[4][];
+
+ try
+ {
+ // for each column in the target matrix
+ for (int i = 0; i < 4; i++)
+ {
+ // construct the rows
+ matrix[i] = new double[4];
+
+ // for each row in the target matrix
+ for (int j = 0; j < 4; j++)
+ {
+ // set the value at [i, j] according to the given generator function
+ this[i, j] = valueGenerator(sourceMatrix, i, j);
+ }
+ }
+ }
+ catch (IndexOutOfRangeException ex)
+ {
+ throw new ArgumentException("Source array is not a minimum of 4x4 in size.", nameof(sourceMatrix), ex);
+ }
+ }
+
+ /// <summary>
+ /// Initialises a new instance of the <see cref="Matrix4x4"/> struct.
+ /// </summary>
+ /// <param name="sourceMatrix">The source matrix.</param>
+ /// <param name="valueGenerator">
+ /// The <see cref="MatrixValueGeneratorDelegate"/> to use to generate new matrix values. Can use the source matrix
+ /// or can ignore it.
+ /// </param>
+ public Matrix4x4(Matrix4x4 sourceMatrix, MatrixValueGeneratorDelegate valueGenerator) :
+ this((double[][])sourceMatrix, valueGenerator)
+ {
+ }
+
+ /// <summary>
+ /// Generates a value to place in the target matrix (at [i, j]), using a source matrix and i and j coordinates.
+ /// </summary>
+ /// <param name="sourceMatrix">The source matrix to use.</param>
+ /// <param name="i">The column index.</param>
+ /// <param name="j">The row index</param>
+ /// <returns>The value to place at the (i, j) position in the new matrix.</returns>
+ public delegate double MatrixValueGeneratorDelegate(double[][] sourceMatrix, int i, int j);
+
+ /// <summary>
+ /// Indexes the matrix as a 2D array.
+ /// </summary>
+ /// <param name="i">The column index.</param>
+ /// <param name="j">The row index.</param>
+ /// <returns>The value at the specified field.</returns>
+ public double this[int i, int j]
+ {
+ get { return matrix[i][j]; }
+ set { matrix[i][j] = value; }
+ }
+
+ /// <summary>
+ /// Implicitly converts a <see cref="Matrix4x4"/> to a 2D <see cref="double"/> array.
+ /// </summary>
+ /// <param name="matrix4x4">The matrix to convert.</param>
+ public static implicit operator double[][](Matrix4x4 matrix4x4)
+ {
+ return matrix4x4.matrix;
+ }
+
+ /// <summary>
+ /// Implements the multiplication operator for a <see cref="Matrix4x4"/> and a <see cref="Vector4d"/>. This is
+ /// the 'dot' operation for a vector and a matrix.
+ /// </summary>
+ /// <param name="matrix4x4">The matrix.</param>
+ /// <param name="vector">The 3D vector.</param>
+ /// <returns>The dot product of the <see cref="Matrix4x4"/> and the <see cref="Vector4d"/>.</returns>
+ public static Vector4d operator *(Matrix4x4 matrix4x4, Vector4d vector)
+ {
+ return new Vector4d
+ {
+ X = vector.X * matrix4x4[0, 0] +
+ vector.Y * matrix4x4[1, 0] +
+ vector.Z * matrix4x4[2, 0] +
+ vector.W * matrix4x4[3, 0],
+ Y = vector.X * matrix4x4[0, 1] +
+ vector.Y * matrix4x4[1, 1] +
+ vector.Z * matrix4x4[2, 1] +
+ vector.W * matrix4x4[3, 1],
+ Z = vector.X * matrix4x4[0, 2] +
+ vector.Y * matrix4x4[1, 2] +
+ vector.Z * matrix4x4[2, 2] +
+ vector.W * matrix4x4[3, 2],
+ W = vector.X * matrix4x4[0, 3] +
+ vector.Y * matrix4x4[1, 3] +
+ vector.Z * matrix4x4[2, 3] +
+ vector.W * matrix4x4[3, 3]
+ };
+ }
+
+ /// <summary>
+ /// Implements the multiplication operator for a <see cref="Matrix4x4"/> and a <see cref="Vector4d"/>. This is
+ /// the 'dot' operation for a vector and a matrix.
+ /// </summary>
+ /// <param name="vector">The 3D vector.</param>
+ /// <param name="matrix4x4">The matrix.</param>
+ /// <returns>The dot product of the <see cref="Matrix4x4"/> and the <see cref="Vector4d"/>.</returns>
+ public static Vector4d operator *(Vector4d vector, Matrix4x4 matrix4x4) => matrix4x4 * vector;
+
+ #region Overrides of ValueType
+
+ /// <inheritdoc />
+ public override string ToString()
+ {
+ return $"[" +
+ $"[{this[0, 0]}, {this[1, 0]}, {this[2, 0]}, {this[3, 0]}]," +
+ $"[{this[0, 1]}, {this[1, 1]}, {this[2, 1]}, {this[3, 1]}]," +
+ $"[{this[0, 2]}, {this[1, 2]}, {this[2, 2]}, {this[3, 2]}]," +
+ $"[{this[0, 3]}, {this[1, 3]}, {this[2, 3]}, {this[3, 3]}]" +
+ $"]";
+ }
+
+ #endregion Overrides of ValueType
+ }
+}
+\ No newline at end of file
diff --git a/StarSim/StarSimLib/Data Structures/Quaternion.cs b/StarSim/StarSimLib/Data Structures/Quaternion.cs
@@ -0,0 +1,9 @@
+namespace StarSimLib.Data_Structures
+{
+ /// <summary>
+ /// Represents a rotation as a set of 4 values.
+ /// </summary>
+ public struct Quaternion
+ {
+ }
+}
+\ No newline at end of file
diff --git a/StarSim/StarSimLib/Data Structures/Vector4d.cs b/StarSim/StarSimLib/Data Structures/Vector4d.cs
@@ -0,0 +1,461 @@
+using System;
+using System.Diagnostics.Contracts;
+
+namespace StarSimLib.Data_Structures
+{
+ /// <summary>
+ /// A 4D vector with <see cref="double"/> components.
+ /// </summary>
+ public struct Vector4d
+ {
+ /// <summary>
+ /// The w component of the vector.
+ /// </summary>
+ public double W;
+
+ /// <summary>
+ /// The x component of the vector.
+ /// </summary>
+ public double X;
+
+ /// <summary>
+ /// The y component of the vector.
+ /// </summary>
+ public double Y;
+
+ /// <summary>
+ /// The z component of the vector.
+ /// </summary>
+ public double Z;
+
+ /// <summary>
+ /// Initialises a new instance of the <see cref="Vector4d"/> struct. Sets Z and W to 0.
+ /// </summary>
+ /// <param name="x">The x component.</param>
+ /// <param name="y">The y component.</param>
+ public Vector4d(double x, double y)
+ {
+ X = x;
+ Y = y;
+ Z = 0;
+ W = 0;
+ }
+
+ /// <summary>
+ /// Initialises a new instance of the <see cref="Vector4d"/> struct. Sets W to 0.
+ /// </summary>
+ /// <param name="x">The x component.</param>
+ /// <param name="y">The y component.</param>
+ /// <param name="z">The z component.</param>
+ public Vector4d(double x, double y, double z)
+ {
+ X = x;
+ Y = y;
+ Z = z;
+ W = 0;
+ }
+
+ /// <summary>
+ /// Initialises a new instance of the <see cref="Vector4d"/> struct.
+ /// </summary>
+ /// <param name="x">The x component.</param>
+ /// <param name="y">The y component.</param>
+ /// <param name="z">The z component.</param>
+ /// <param name="w">The w component.</param>
+ public Vector4d(double x, double y, double z, double w)
+ {
+ X = x;
+ Y = y;
+ Z = z;
+ W = w;
+ }
+
+ #region Operator Overloads
+
+ /// <summary>
+ /// Implements the subtraction operator for 2 <see cref="Vector4d"/>s.
+ /// </summary>
+ /// <param name="vector">The original <see cref="Vector4d"/>.</param>
+ /// <param name="vector2">The other <see cref="Vector4d"/>.</param>
+ /// <returns>The new <see cref="Vector4d"/>.</returns>
+ public static Vector4d operator -(Vector4d vector, Vector4d vector2)
+ {
+ vector.X -= vector2.X;
+ vector.Y -= vector2.Y;
+ vector.Z -= vector2.Z;
+ vector.W -= vector2.W;
+
+ return vector;
+ }
+
+ /// <summary>
+ /// Implements the subtraction operator for a <see cref="Vector4d"/> and a (X, Y, Z, W) tuple.
+ /// </summary>
+ /// <param name="vector">The original <see cref="Vector4d"/>.</param>
+ /// <param name="vector2">The 4D tuple.</param>
+ /// <returns>The new <see cref="Vector4d"/>.</returns>
+ public static Vector4d operator -(Vector4d vector, (double X, double Y, double Z, double W) vector2)
+ {
+ (double x, double y, double z, double w) = vector2;
+
+ vector.X -= x;
+ vector.Y -= y;
+ vector.Z -= z;
+ vector.W -= w;
+
+ return vector;
+ }
+
+ /// <summary>
+ /// Implements the subtraction operator for a <see cref="Vector4d"/> and a (X, Y, Z, W) tuple.
+ /// </summary>
+ /// <param name="vector">The original <see cref="Vector4d"/>.</param>
+ /// <param name="vector2">The 4D tuple.</param>
+ /// <returns>The new <see cref="Vector4d"/>.</returns>
+ public static Vector4d operator -((double X, double Y, double Z, double W) vector2, Vector4d vector) => vector - vector2;
+
+ /// <summary>
+ /// Implements the subtraction operator for a <see cref="Vector4d"/> and a scalar <see cref="double"/> value.
+ /// </summary>
+ /// <param name="vector">The original <see cref="Vector4d"/>.</param>
+ /// <param name="scalar">The scalar <see cref="double"/>.</param>
+ /// <returns>The new <see cref="Vector4d"/>.</returns>
+ public static Vector4d operator -(Vector4d vector, double scalar)
+ {
+ vector.X -= scalar;
+ vector.Y -= scalar;
+ vector.Z -= scalar;
+ vector.W -= scalar;
+
+ return vector;
+ }
+
+ /// <summary>
+ /// Implements the subtraction operator for a <see cref="Vector4d"/> and a scalar <see cref="double"/> value.
+ /// </summary>
+ /// <param name="vector">The original <see cref="Vector4d"/>.</param>
+ /// <param name="scalar">The scalar <see cref="double"/>.</param>
+ /// <returns>The new <see cref="Vector4d"/>.</returns>
+ public static Vector4d operator -(double scalar, Vector4d vector) => vector - scalar;
+
+ /// <summary>
+ /// Implements the multiplication operator for 2 <see cref="Vector4d"/>s.
+ /// </summary>
+ /// <param name="vector">The original <see cref="Vector4d"/>.</param>
+ /// <param name="vector2">The other <see cref="Vector4d"/>.</param>
+ /// <returns>The new <see cref="Vector4d"/>.</returns>
+ public static Vector4d operator *(Vector4d vector, Vector4d vector2)
+ {
+ vector.X *= vector2.X;
+ vector.Y *= vector2.Y;
+ vector.Z *= vector2.Z;
+ vector.W *= vector2.W;
+
+ return vector;
+ }
+
+ /// <summary>
+ /// Implements the multiplication operator for a <see cref="Vector4d"/> and a (X, Y, Z, W) tuple.
+ /// </summary>
+ /// <param name="vector">The original <see cref="Vector4d"/>.</param>
+ /// <param name="vector2">The 4D tuple.</param>
+ /// <returns>The new <see cref="Vector4d"/>.</returns>
+ public static Vector4d operator *(Vector4d vector, (double X, double Y, double Z, double W) vector2)
+ {
+ (double x, double y, double z, double w) = vector2;
+
+ vector.X *= x;
+ vector.Y *= y;
+ vector.Z *= z;
+ vector.W *= w;
+
+ return vector;
+ }
+
+ /// <summary>
+ /// Implements the multiplication operator for a <see cref="Vector4d"/> and a (X, Y, Z, W) tuple.
+ /// </summary>
+ /// <param name="vector">The original <see cref="Vector4d"/>.</param>
+ /// <param name="vector2">The 4D tuple.</param>
+ /// <returns>The new <see cref="Vector4d"/>.</returns>
+ public static Vector4d operator *((double X, double Y, double Z, double W) vector2, Vector4d vector) => vector * vector2;
+
+ /// <summary>
+ /// Implements the multiplication operator for a <see cref="Vector4d"/> and a scalar <see cref="double"/> value.
+ /// </summary>
+ /// <param name="vector">The original <see cref="Vector4d"/>.</param>
+ /// <param name="scalar">The scalar <see cref="double"/>.</param>
+ /// <returns>The new <see cref="Vector4d"/>.</returns>
+ public static Vector4d operator *(Vector4d vector, double scalar)
+ {
+ vector.X *= scalar;
+ vector.Y *= scalar;
+ vector.Z *= scalar;
+ vector.W *= scalar;
+
+ return vector;
+ }
+
+ /// <summary>
+ /// Implements the multiplication operator for a <see cref="Vector4d"/> and a scalar <see cref="double"/> value.
+ /// </summary>
+ /// <param name="vector">The original <see cref="Vector4d"/>.</param>
+ /// <param name="scalar">The scalar <see cref="double"/>.</param>
+ /// <returns>The new <see cref="Vector4d"/>.</returns>
+ public static Vector4d operator *(double scalar, Vector4d vector) => vector * scalar;
+
+ /// <summary>
+ /// Implements the division operator for 2 <see cref="Vector4d"/>s.
+ /// </summary>
+ /// <param name="vector">The original <see cref="Vector4d"/>.</param>
+ /// <param name="vector2">The other <see cref="Vector4d"/>.</param>
+ /// <returns>The new <see cref="Vector4d"/>.</returns>
+ public static Vector4d operator /(Vector4d vector, Vector4d vector2)
+ {
+ vector.X /= vector2.X;
+ vector.Y /= vector2.Y;
+ vector.Z /= vector2.Z;
+ vector.W /= vector2.W;
+
+ return vector;
+ }
+
+ /// <summary>
+ /// Implements the division operator for a <see cref="Vector4d"/> and a (X, Y, Z, W) tuple.
+ /// </summary>
+ /// <param name="vector">The original <see cref="Vector4d"/>.</param>
+ /// <param name="vector2">The 4D tuple.</param>
+ /// <returns>The new <see cref="Vector4d"/>.</returns>
+ public static Vector4d operator /(Vector4d vector, (double X, double Y, double Z, double W) vector2)
+ {
+ (double x, double y, double z, double w) = vector2;
+
+ vector.X /= x;
+ vector.Y /= y;
+ vector.Z /= z;
+ vector.W /= w;
+
+ return vector;
+ }
+
+ /// <summary>
+ /// Implements the division operator for a <see cref="Vector4d"/> and a (X, Y, Z, W) tuple.
+ /// </summary>
+ /// <param name="vector">The original <see cref="Vector4d"/>.</param>
+ /// <param name="vector2">The 4D tuple.</param>
+ /// <returns>The new <see cref="Vector4d"/>.</returns>
+ public static Vector4d operator /((double X, double Y, double Z, double W) vector2, Vector4d vector) => vector / vector2;
+
+ /// <summary>
+ /// Implements the division operator for a <see cref="Vector4d"/> and a scalar <see cref="double"/> value.
+ /// </summary>
+ /// <param name="vector">The original <see cref="Vector4d"/>.</param>
+ /// <param name="scalar">The scalar <see cref="double"/>.</param>
+ /// <returns>The new <see cref="Vector4d"/>.</returns>
+ public static Vector4d operator /(Vector4d vector, double scalar)
+ {
+ vector.X /= scalar;
+ vector.Y /= scalar;
+ vector.Z /= scalar;
+ vector.W /= scalar;
+
+ return vector;
+ }
+
+ /// <summary>
+ /// Implements the division operator for a <see cref="Vector4d"/> and a scalar <see cref="double"/> value.
+ /// </summary>
+ /// <param name="vector">The original <see cref="Vector4d"/>.</param>
+ /// <param name="scalar">The scalar <see cref="double"/>.</param>
+ /// <returns>The new <see cref="Vector4d"/>.</returns>
+ public static Vector4d operator /(double scalar, Vector4d vector) => vector / scalar;
+
+ /// <summary>
+ /// Implements the addition operator for 2 <see cref="Vector4d"/>s.
+ /// </summary>
+ /// <param name="vector">The original <see cref="Vector4d"/>.</param>
+ /// <param name="vector2">The other <see cref="Vector4d"/>.</param>
+ /// <returns>The new <see cref="Vector4d"/>.</returns>
+ public static Vector4d operator +(Vector4d vector, Vector4d vector2)
+ {
+ vector.X += vector2.X;
+ vector.Y += vector2.Y;
+ vector.Z += vector2.Z;
+ vector.W += vector2.W;
+
+ return vector;
+ }
+
+ /// <summary>
+ /// Implements the addition operator for a <see cref="Vector4d"/> and a (X, Y, Z, W) tuple.
+ /// </summary>
+ /// <param name="vector">The original <see cref="Vector4d"/>.</param>
+ /// <param name="vector2">The 4D tuple.</param>
+ /// <returns>The new <see cref="Vector4d"/>.</returns>
+ public static Vector4d operator +(Vector4d vector, (double X, double Y, double Z, double W) vector2)
+ {
+ (double x, double y, double z, double w) = vector2;
+
+ vector.X += x;
+ vector.Y += y;
+ vector.Z += z;
+ vector.W += w;
+
+ return vector;
+ }
+
+ /// <summary>
+ /// Implements the addition operator for a <see cref="Vector4d"/> and a (X, Y, Z, W) tuple.
+ /// </summary>
+ /// <param name="vector">The original <see cref="Vector4d"/>.</param>
+ /// <param name="vector2">The 4D tuple.</param>
+ /// <returns>The new <see cref="Vector4d"/>.</returns>
+ public static Vector4d operator +((double X, double Y, double Z, double W) vector2, Vector4d vector) => vector + vector2;
+
+ /// <summary>
+ /// Implements the addition operator for a <see cref="Vector4d"/> and a scalar <see cref="double"/> value.
+ /// </summary>
+ /// <param name="vector">The original <see cref="Vector4d"/>.</param>
+ /// <param name="scalar">The scalar <see cref="double"/>.</param>
+ /// <returns>The new <see cref="Vector4d"/>.</returns>
+ public static Vector4d operator +(Vector4d vector, double scalar)
+ {
+ vector.X += scalar;
+ vector.Y += scalar;
+ vector.Z += scalar;
+ vector.W += scalar;
+
+ return vector;
+ }
+
+ /// <summary>
+ /// Implements the addition operator for a <see cref="Vector4d"/> and a scalar <see cref="double"/> value.
+ /// </summary>
+ /// <param name="vector">The original <see cref="Vector4d"/>.</param>
+ /// <param name="scalar">The scalar <see cref="double"/>.</param>
+ /// <returns>The new <see cref="Vector4d"/>.</returns>
+ public static Vector4d operator +(double scalar, Vector4d vector) => vector + scalar;
+
+ #endregion Operator Overloads
+
+ /// <summary>
+ /// Indexes the vector as a 1D array.
+ /// </summary>
+ /// <param name="i">The column index.</param>
+ /// <returns>The value at the specified field.</returns>
+ public double this[int i]
+ {
+ get
+ {
+ switch (i)
+ {
+ case 0:
+ return X;
+
+ case 1:
+ return Y;
+
+ case 2:
+ return Z;
+
+ case 3:
+ return W;
+
+ default:
+ return 0;
+ }
+ }
+
+ set
+ {
+ switch (i)
+ {
+ case 0:
+ X = value;
+ break;
+
+ case 1:
+ Y = value;
+ break;
+
+ case 2:
+ Z = value;
+ break;
+
+ case 3:
+ W = value;
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Returns the absolute value of this <see cref="Vector4d"/>.
+ /// </summary>
+ /// <returns>The absolute value (magnitude) of this <see cref="Vector4d"/>, as a <see cref="double"/>.</returns>
+ [Pure]
+ public double Abs()
+ {
+ return Math.Sqrt(X * X + Y * Y + Z * Z + W * W);
+ }
+
+ /// <summary>
+ /// Returns the magnitude of this <see cref="Vector4d"/>.
+ /// </summary>
+ /// <returns>The magnitude (absolute value) of this <see cref="Vector4d"/>, as a <see cref="double"/>.</returns>
+ [Pure]
+ public double Magnitude()
+ {
+ return Abs();
+ }
+
+ /// <summary>
+ /// Holds unit vectors.
+ /// </summary>
+ public static class UnitVectors
+ {
+ /// <summary>
+ /// The negative unit vector for the Z axis.
+ /// </summary>
+ public static readonly Vector4d Backwards = new Vector4d(0, 0, -1);
+
+ /// <summary>
+ /// The negative unit vector for the Y axis.
+ /// </summary>
+ public static readonly Vector4d Down = new Vector4d(0, -1, 0);
+
+ /// <summary>
+ /// The positive unit vector for the Z axis.
+ /// </summary>
+ public static readonly Vector4d Forwards = new Vector4d(0, 0, 1);
+
+ /// <summary>
+ /// The positive unit vector for the X axis.
+ /// </summary>
+ public static readonly Vector4d Left = new Vector4d(1, 0, 0);
+
+ /// <summary>
+ /// The negative unit vector for the X axis.
+ /// </summary>
+ public static readonly Vector4d Right = new Vector4d(-1, 0, 0);
+
+ /// <summary>
+ /// The positive unit vector for the Y axis.
+ /// </summary>
+ public static readonly Vector4d Up = new Vector4d(0, 1, 0);
+ }
+
+ #region Overrides of ValueType
+
+ /// <inheritdoc />
+ public override string ToString()
+ {
+ return $"[{X}, {Y}, {Z}, {W}]";
+ }
+
+ #endregion Overrides of ValueType
+ }
+}
+\ No newline at end of file
diff --git a/StarSim/StarSimLib/Graphics/Drawer.cs b/StarSim/StarSimLib/Graphics/Drawer.cs
@@ -2,40 +2,78 @@
using System.Collections.Generic;
using SFML.Graphics;
using SFML.System;
+using StarSimLib.Data_Structures;
using StarSimLib.Physics;
namespace StarSimLib.Graphics
{
/// <summary>
+ /// Enumerates all possible rotation directions (i.e. north, east, south, west, clockwise, anticlockwise).
+ /// </summary>
+ public enum RotationDirection
+ {
+ /// <summary>
+ /// Represents an anticlockwise rotation in the x-axis.
+ /// </summary>
+ North,
+
+ /// <summary>
+ /// Represents an anticlockwise rotation in the y-axis.
+ /// </summary>
+ East,
+
+ /// <summary>
+ /// Represents a clockwise rotation in the x-axis.
+ /// </summary>
+ South,
+
+ /// <summary>
+ /// Represents a clockwise rotation in the y-axis.
+ /// </summary>
+ West,
+
+ /// <summary>
+ /// Represents a clockwise rotation in the z-axis.
+ /// </summary>
+ Clockwise,
+
+ /// <summary>
+ /// Represents an anticlockwise rotation in the z-axis.
+ /// </summary>
+ Anticlockwise
+ }
+
+ /// <summary>
/// Represents a drawer capable of rendering bodies to a <see cref="RenderTarget"/>.
/// </summary>
public class Drawer
{
/// <summary>
+ /// Conversion from degrees to radians, as used by the <see cref="Math"/> functions.
+ /// </summary>
+ private const double DegToRad = 1d / 180 * Math.PI;
+
+ /// <summary>
/// The furthest distance that can be seen on the <see cref="RenderTarget"/>. Any bodies that are further
/// from the camera than this distance are culled and not rendered.
/// </summary>
- private const double farDistance = 1 * Constants.UniverseSize;
+ private const double FarDistance = 1 * Constants.UniverseSize;
/// <summary>
- /// The field of view for the drawer in degrees.
+ /// The default field of view for the drawer in degrees.
/// </summary>
- private const double fieldOfView = 45;
+ private const double FieldOfView = 45;
/// <summary>
/// The closest distance that can be seen on the <see cref="RenderTarget"/>. Any bodies that are closer
/// to the camera than this distance (i.e. behind the camera) are culled and not rendered.
/// </summary>
- private const double nearDistance = 0;
-
- /// <summary>
- /// Inverse scale factor used in the projection matrix.
- /// </summary>
- private static readonly double inverseScaleFactor = 1 / Math.Tan(fieldOfView * 0.5 / 180 * Math.PI);
+ private const double NearDistance = 0;
/// <summary>
/// The aspect ratio of the render target. Allows for normalisation of the <see cref="RenderTarget"/> space
- /// into a normal plane ([-1, -1] = top left, [1, 1] = bottom right).
+ /// into a normal plane ([-1, -1] = top left, [1, 1] = bottom right), instead of having to deal with a
+ /// variable render space.
/// </summary>
private readonly double aspectRatio;
@@ -57,23 +95,60 @@ namespace StarSimLib.Graphics
private readonly Vector2u originOffset;
/// <summary>
+ /// The target to which the managed bodies will be drawn.
+ /// </summary>
+ private readonly RenderTarget renderTarget;
+
+ /// <summary>
+ /// The current value for the field of view, in degrees. Used to zoom the view in and out.
+ /// </summary>
+ private double currentFieldOfView = FieldOfView;
+
+ /// <summary>
/// Projection matrix used for mapping from 3D to 2D.
/// </summary>
- private readonly Matrix4x4 projectionMatrix;
+ private Matrix4x4 projectionMatrix;
/// <summary>
- /// The target to which the managed bodies will be drawn.
+ /// Angle of rotation in the x axis.
/// </summary>
- private readonly RenderTarget renderTarget;
+ private double xAngle = 0;
+
+ /// <summary>
+ /// The rotation matrix for the x axis.
+ /// </summary>
+ private Matrix4x4 xRotationMatrix;
+
+ /// <summary>
+ /// Angle of rotation in the y axis.
+ /// </summary>
+ private double yAngle = 0;
+
+ /// <summary>
+ /// The rotation matrix for the y axis.
+ /// </summary>
+ private Matrix4x4 yRotationMatrix;
+
+ /// <summary>
+ /// Angle of rotation in the z axis.
+ /// </summary>
+ private double zAngle = 0;
+
+ /// <summary>
+ /// The rotation matrix for the z axis.
+ /// </summary>
+ private Matrix4x4 zRotationMatrix;
/// <summary>
/// Initialises a new instance of the <see cref="Drawer"/> class.
/// </summary>
/// <param name="target">The target to which the managed bodies should be rendered.</param>
- /// <param name="bodies">The <see cref="Body"/> instances which should be managed by this instance.</param>
+ /// <param name="bodies">
+ /// A reference to the <see cref="Body"/> instances which should be managed by this instance.
+ /// </param>
/// <param name="bodyShapeMap">
- /// Maps a <see cref="Body"/> instance to the <see cref="CircleShape"/> that represents it, and is drawn to the
- /// screen at the <see cref="Body"/> instances position.
+ /// A reference to the dictionary mapping a <see cref="Body"/> instance to the <see cref="CircleShape"/> that
+ /// represents it, and is drawn to the screen at the <see cref="Body"/> instance's position.
/// </param>
public Drawer(RenderTarget target, ref Body[] bodies, ref Dictionary<Body, CircleShape> bodyShapeMap)
{
@@ -84,17 +159,96 @@ namespace StarSimLib.Graphics
projectionMatrix = new Matrix4x4(new[]
{
- new [] { aspectRatio * inverseScaleFactor, 0, 0, 0 },
- new [] { 0, inverseScaleFactor, 0, 0 },
- new [] { 0, 0, farDistance / (farDistance - nearDistance), 1 },
- new [] { 0, 0, -farDistance * nearDistance / (farDistance - nearDistance), 0 }
+ new [] { aspectRatio * InverseScaleFactor, 0, 0, 0 },
+ new [] { 0, InverseScaleFactor, 0, 0 },
+ new [] { 0, 0, FarDistance / (FarDistance - NearDistance), 1 },
+ new [] { 0, 0, -FarDistance * NearDistance / (FarDistance - NearDistance), 0 }
});
+ xRotationMatrix = new Matrix4x4(new[]
+ {
+ new [] { 1d, 0, 0, 0 },
+ new [] { 0d, 0, 0, 0 },
+ new [] { 0d, 0, 0, 0 },
+ new [] { 0d, 0, 0, 1 }
+ });
+
+ yRotationMatrix = new Matrix4x4(new[]
+ {
+ new [] { 0d, 0, 0, 0 },
+ new [] { 0d, 1, 0, 0 },
+ new [] { 0d, 0, 0, 0 },
+ new [] { 0d, 0, 0, 1 }
+ });
+
+ zRotationMatrix = new Matrix4x4(new[]
+ {
+ new [] { 0d, 0, 0, 0 },
+ new [] { 0d, 0, 0, 0 },
+ new [] { 0d, 0, 1, 0 },
+ new [] { 0d, 0, 0, 1 }
+ });
+
+ UpdateRotationMatrices();
+
managedBodies = bodies;
managedBodyShapeMap = bodyShapeMap;
}
/// <summary>
+ /// Inverse scale factor used in the projection matrix.
+ /// </summary>
+ private double InverseScaleFactor { get { return 1 / Math.Tan(currentFieldOfView * 0.5 * DegToRad); } }
+
+ /// <summary>
+ /// Current angle of rotation in the x axis.
+ /// </summary>
+ public double XAngle
+ {
+ get { return xAngle; }
+ }
+
+ /// <summary>
+ /// Current angle of rotation in the x axis.
+ /// </summary>
+ public double YAngle
+ {
+ get { return yAngle; }
+ }
+
+ /// <summary>
+ /// Current angle of rotation in the x axis.
+ /// </summary>
+ public double ZAngle
+ {
+ get { return zAngle; }
+ }
+
+ /// <summary>
+ /// Updates the rotation matrices for the view.
+ /// </summary>
+ private void UpdateRotationMatrices()
+ {
+ // update the rotation matrix values for the x axis
+ xRotationMatrix[1, 1] = Math.Cos(xAngle * DegToRad);
+ xRotationMatrix[1, 2] = -Math.Sin(xAngle * DegToRad);
+ xRotationMatrix[2, 1] = Math.Sin(xAngle * DegToRad);
+ xRotationMatrix[2, 2] = Math.Cos(xAngle * DegToRad);
+
+ // update the rotation matrix values for the y axis
+ yRotationMatrix[0, 0] = Math.Cos(yAngle * DegToRad);
+ yRotationMatrix[0, 2] = Math.Sin(yAngle * DegToRad);
+ yRotationMatrix[2, 0] = -Math.Sin(yAngle * DegToRad);
+ yRotationMatrix[2, 2] = Math.Cos(yAngle * DegToRad);
+
+ // update the rotation matrix values for the z axis
+ zRotationMatrix[0, 0] = Math.Cos(zAngle * DegToRad);
+ zRotationMatrix[0, 1] = -Math.Sin(zAngle * DegToRad);
+ zRotationMatrix[1, 0] = Math.Sin(zAngle * DegToRad);
+ zRotationMatrix[1, 1] = Math.Cos(zAngle * DegToRad);
+ }
+
+ /// <summary>
/// Draws each <see cref="Body"/> instance that is managed by this drawer to the <see cref="RenderTarget"/> specified
/// in the constructor.
/// </summary>
@@ -109,9 +263,15 @@ namespace StarSimLib.Graphics
// rotations should happen before the body is translated into camera space
Vector4d worldSpace = body.Position;
+ // rotations of points in the x, y and z axes
+ worldSpace *= zRotationMatrix;
+ worldSpace *= yRotationMatrix;
+ worldSpace *= xRotationMatrix;
+
// bodies must be translated into the camera space, as the camera must be some distance away from the
- // world space origin (0,0,0). otherwise rendering breaks
- Vector4d cameraSpace = worldSpace + new Vector4d(0, 0, (farDistance - nearDistance) / 2);
+ // world space origin (0,0,0) or else rendering breaks. the bodies are translated into the middle of
+ // camera space.
+ Vector4d cameraSpace = worldSpace + new Vector4d(0, 0, (FarDistance - NearDistance) / 2);
// project the body position from camera space into screen space (without any special transformations)
Vector4d projectedPosition = cameraSpace * projectionMatrix;
@@ -138,16 +298,61 @@ namespace StarSimLib.Graphics
}
/// <summary>
+ /// Rotates the view in the given direction, by the specified angle (in degrees).
+ /// </summary>
+ /// <param name="direction">The direction in which to rotate the view.</param>
+ /// <param name="angle">The angle by which to rotate in the given direction.</param>
+ public void Rotate(RotationDirection direction, double angle)
+ {
+ switch (direction)
+ {
+ case RotationDirection.North:
+ xAngle += angle % 360;
+ break;
+
+ case RotationDirection.East:
+ yAngle += angle % 360;
+ break;
+
+ case RotationDirection.South:
+ xAngle -= angle % 360;
+ break;
+
+ case RotationDirection.West:
+ yAngle -= angle % 360;
+ break;
+
+ case RotationDirection.Clockwise:
+ zAngle -= angle % 360;
+ break;
+
+ case RotationDirection.Anticlockwise:
+ zAngle += angle % 360;
+ break;
+
+ default:
+ throw new ArgumentOutOfRangeException(nameof(direction), direction, "The given direction was not within the valid range.");
+ }
+
+ xAngle %= 360;
+ yAngle %= 360;
+ zAngle %= 360;
+
+ UpdateRotationMatrices();
+ }
+
+ /// <summary>
/// Scales this instances view by the given amount.
/// </summary>
/// <param name="scaleMultiplier">The multiplier by which to scale the viewport of this instances render target.</param>
- public void Scale(float scaleMultiplier)
+ public void Scale(double scaleMultiplier)
{
- View renderView = renderTarget.GetView();
-
- renderView.Zoom(scaleMultiplier);
+ currentFieldOfView /= scaleMultiplier;
- renderTarget.SetView(renderView);
+ // reassign projection matrix fields as the field of view (used by InverseScaleFactor) has been
+ // modified to zoom in or out
+ projectionMatrix[0, 0] = aspectRatio * InverseScaleFactor;
+ projectionMatrix[1, 1] = InverseScaleFactor;
}
}
}
\ No newline at end of file
diff --git a/StarSim/StarSimLib/Matrix4x4.cs b/StarSim/StarSimLib/Matrix4x4.cs
@@ -1,180 +0,0 @@
-using System;
-
-namespace StarSimLib
-{
- /// <summary>
- /// A 4-by-4 matrix of <see cref="double"/> values.
- /// </summary>
- public struct Matrix4x4
- {
- /// <summary>
- /// The internal matrix representation.
- /// </summary>
- private readonly double[][] matrix;
-
- /// <summary>
- /// The default <see cref="MatrixValueGeneratorDelegate"/> to use when constructing a <see cref="Matrix4x4"/>
- /// from a given 2D <see cref="double"/> array. Simply copies over the values from the source matrix to the
- /// output matrix. Should the source matrix contain null fields, a 0 will be placed at the relevant field in
- /// the target matrix.
- /// </summary>
- public static readonly MatrixValueGeneratorDelegate CopyMatrixValuesGeneratorDelegate =
- (sourceMatrix, i, j) => sourceMatrix?[i]?[j] ?? 0;
-
- /// <summary>
- /// Initialises a new instance of the <see cref="Matrix4x4"/> struct.
- /// </summary>
- /// <param name="defaultValue">The value to which to initialise all fields in the matrix.</param>
- public Matrix4x4(double defaultValue) : this(null, (sourceMatrix, i, j) => defaultValue)
- {
- }
-
- /// <summary>
- /// Initialises a new instance of the <see cref="Matrix4x4"/> struct.
- /// </summary>
- /// <param name="sourceMatrix">The source matrix from which to copy over values.</param>
- public Matrix4x4(double[][] sourceMatrix) : this(sourceMatrix, CopyMatrixValuesGeneratorDelegate)
- {
- }
-
- /// <summary>
- /// Initialises a new instance of the <see cref="Matrix4x4"/> struct.
- /// </summary>
- /// <param name="sourceMatrix">The source matrix from which to copy over values.</param>
- public Matrix4x4(Matrix4x4 sourceMatrix) : this(sourceMatrix, CopyMatrixValuesGeneratorDelegate)
- {
- }
-
- /// <summary>
- /// Initialises a new instance of the <see cref="Matrix4x4"/> struct.
- /// </summary>
- /// <param name="sourceMatrix">The source matrix.</param>
- /// <param name="valueGenerator">
- /// The <see cref="MatrixValueGeneratorDelegate"/> to use to generate new matrix values. Can use the source matrix
- /// or can ignore it.
- /// </param>
- public Matrix4x4(double[][] sourceMatrix, MatrixValueGeneratorDelegate valueGenerator)
- {
- // construct the columns
- matrix = new double[4][];
-
- try
- {
- // for each column in the target matrix
- for (int i = 0; i < 4; i++)
- {
- // construct the rows
- matrix[i] = new double[4];
-
- // for each row in the target matrix
- for (int j = 0; j < 4; j++)
- {
- // set the value at [i, j] according to the given generator function
- this[i, j] = valueGenerator(sourceMatrix, i, j);
- }
- }
- }
- catch (IndexOutOfRangeException ex)
- {
- throw new ArgumentException("Source array is not a minimum of 4x4 in size.", nameof(sourceMatrix), ex);
- }
- }
-
- /// <summary>
- /// Initialises a new instance of the <see cref="Matrix4x4"/> struct.
- /// </summary>
- /// <param name="sourceMatrix">The source matrix.</param>
- /// <param name="valueGenerator">
- /// The <see cref="MatrixValueGeneratorDelegate"/> to use to generate new matrix values. Can use the source matrix
- /// or can ignore it.
- /// </param>
- public Matrix4x4(Matrix4x4 sourceMatrix, MatrixValueGeneratorDelegate valueGenerator) :
- this((double[][])sourceMatrix, valueGenerator)
- {
- }
-
- /// <summary>
- /// Generates a value to place in the target matrix (at [i, j]), using a source matrix and i and j coordinates.
- /// </summary>
- /// <param name="sourceMatrix">The source matrix to use.</param>
- /// <param name="i">The column index.</param>
- /// <param name="j">The row index</param>
- /// <returns>The value to place at the (i, j) position in the new matrix.</returns>
- public delegate double MatrixValueGeneratorDelegate(double[][] sourceMatrix, int i, int j);
-
- /// <summary>
- /// Indexes the matrix as a 2D array.
- /// </summary>
- /// <param name="i">The column index.</param>
- /// <param name="j">The row index.</param>
- /// <returns>The value at the specified field.</returns>
- public double this[int i, int j]
- {
- get { return matrix[i][j]; }
- set { matrix[i][j] = value; }
- }
-
- /// <summary>
- /// Implicitly converts a <see cref="Matrix4x4"/> to a 2D <see cref="double"/> array.
- /// </summary>
- /// <param name="matrix4x4">The matrix to convert.</param>
- public static implicit operator double[][](Matrix4x4 matrix4x4)
- {
- return matrix4x4.matrix;
- }
-
- /// <summary>
- /// Implements the multiplication operator for a <see cref="Matrix4x4"/> and a <see cref="Vector4d"/>. This is
- /// the 'dot' operation for a vector and a matrix.
- /// </summary>
- /// <param name="matrix4x4">The matrix.</param>
- /// <param name="vector">The 3D vector.</param>
- /// <returns>The dot product of the <see cref="Matrix4x4"/> and the <see cref="Vector4d"/>.</returns>
- public static Vector4d operator *(Matrix4x4 matrix4x4, Vector4d vector)
- {
- return new Vector4d
- {
- X = vector.X * matrix4x4[0, 0] +
- vector.Y * matrix4x4[1, 0] +
- vector.Z * matrix4x4[2, 0] +
- vector.W * matrix4x4[3, 0],
- Y = vector.X * matrix4x4[0, 1] +
- vector.Y * matrix4x4[1, 1] +
- vector.Z * matrix4x4[2, 1] +
- vector.W * matrix4x4[3, 1],
- Z = vector.X * matrix4x4[0, 2] +
- vector.Y * matrix4x4[1, 2] +
- vector.Z * matrix4x4[2, 2] +
- vector.W * matrix4x4[3, 2],
- W = vector.X * matrix4x4[0, 3] +
- vector.Y * matrix4x4[1, 3] +
- vector.Z * matrix4x4[2, 3] +
- vector.W * matrix4x4[3, 3]
- };
- }
-
- /// <summary>
- /// Implements the multiplication operator for a <see cref="Matrix4x4"/> and a <see cref="Vector4d"/>. This is
- /// the 'dot' operation for a vector and a matrix.
- /// </summary>
- /// <param name="vector">The 3D vector.</param>
- /// <param name="matrix4x4">The matrix.</param>
- /// <returns>The dot product of the <see cref="Matrix4x4"/> and the <see cref="Vector4d"/>.</returns>
- public static Vector4d operator *(Vector4d vector, Matrix4x4 matrix4x4) => matrix4x4 * vector;
-
- #region Overrides of ValueType
-
- /// <inheritdoc />
- public override string ToString()
- {
- return $"[" +
- $"[{this[0, 0]}, {this[1, 0]}, {this[2, 0]}, {this[3, 0]}]," +
- $"[{this[0, 1]}, {this[1, 1]}, {this[2, 1]}, {this[3, 1]}]," +
- $"[{this[0, 2]}, {this[1, 2]}, {this[2, 2]}, {this[3, 2]}]," +
- $"[{this[0, 3]}, {this[1, 3]}, {this[2, 3]}, {this[3, 3]}]" +
- $"]";
- }
-
- #endregion Overrides of ValueType
- }
-}
-\ No newline at end of file
diff --git a/StarSim/StarSimLib/Physics/Body.cs b/StarSim/StarSimLib/Physics/Body.cs
@@ -1,4 +1,5 @@
using System;
+using StarSimLib.Data_Structures;
namespace StarSimLib.Physics
{
diff --git a/StarSim/StarSimLib/Physics/BodyGenerator.cs b/StarSim/StarSimLib/Physics/BodyGenerator.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using SFML.Graphics;
using SFML.System;
+using StarSimLib.Data_Structures;
namespace StarSimLib.Physics
{
diff --git a/StarSim/StarSimLib/Physics/BodyUpdater.cs b/StarSim/StarSimLib/Physics/BodyUpdater.cs
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
+using StarSimLib.Data_Structures;
namespace StarSimLib.Physics
{
diff --git a/StarSim/StarSimLib/Physics/OrbitGenerator.cs b/StarSim/StarSimLib/Physics/OrbitGenerator.cs
@@ -1,4 +1,5 @@
using System;
+using StarSimLib.Data_Structures;
namespace StarSimLib.Physics
{
diff --git a/StarSim/StarSimLib/StarSimLib.xml b/StarSim/StarSimLib/StarSimLib.xml
@@ -19,6 +19,11 @@
The mass of the central body, if it is included.
</summary>
</member>
+ <member name="F:StarSimLib.Constants.EulerRotationStep">
+ <summary>
+ The amount of degrees by which the view will be rotated in any given direction.
+ </summary>
+ </member>
<member name="F:StarSimLib.Constants.FrameRate">
<summary>
The frame rate limit for the program.
@@ -59,14 +64,14 @@
The time step for the simulation.
</summary>
</member>
- <member name="F:StarSimLib.Constants.UniverseScalingFactor">
+ <member name="F:StarSimLib.Constants.UniverseSize">
<summary>
- Factor by which to multiply the position of <see cref="T:StarSimLib.Physics.Body"/>s to scale them to the screen for displaying.
+ The maximum radius within which <see cref="T:StarSimLib.Physics.Body"/>s will be placed (1e18f).
</summary>
</member>
- <member name="F:StarSimLib.Constants.UniverseSize">
+ <member name="F:StarSimLib.Constants.ZoomStep">
<summary>
- The maximum radius within which <see cref="T:StarSimLib.Physics.Body"/>s will be placed (1e18f).
+ The amount by which the zoom level will be increased or decreased.
</summary>
</member>
<member name="T:StarSimLib.Contexts.SimulatorContext">
@@ -96,662 +101,772 @@
<member name="M:StarSimLib.Contexts.SimulatorContext.OnModelCreating(Microsoft.EntityFrameworkCore.ModelBuilder)">
<inheritdoc />
</member>
- <member name="T:StarSimLib.Extensions.Vector3fExtensions">
+ <member name="T:StarSimLib.Data_Structures.Matrix4x4">
<summary>
- Provides additional functionality to the <see cref="T:SFML.System.Vector3f"/> struct.
+ A 4-by-4 matrix of <see cref="T:System.Double"/> values.
</summary>
</member>
- <member name="M:StarSimLib.Extensions.Vector3fExtensions.Magnitude(SFML.System.Vector3f)">
+ <member name="F:StarSimLib.Data_Structures.Matrix4x4.matrix">
<summary>
- Returns the magnitude of the given <see cref="T:SFML.System.Vector3f"/>.
+ The internal matrix representation.
</summary>
- <param name="vector">The vector whose magnitude to return.</param>
- <returns>The magnitude of the given <see cref="T:SFML.System.Vector3f"/>.</returns>
</member>
- <member name="T:StarSimLib.Graphics.Drawer">
+ <member name="F:StarSimLib.Data_Structures.Matrix4x4.CopyMatrixValuesGeneratorDelegate">
<summary>
- Represents a drawer capable of rendering bodies to a <see cref="T:SFML.Graphics.RenderTarget"/>.
+ The default <see cref="T:StarSimLib.Data_Structures.Matrix4x4.MatrixValueGeneratorDelegate"/> to use when constructing a <see cref="T:StarSimLib.Data_Structures.Matrix4x4"/>
+ from a given 2D <see cref="T:System.Double"/> array. Simply copies over the values from the source matrix to the
+ output matrix. Should the source matrix contain null fields, a 0 will be placed at the relevant field in
+ the target matrix.
</summary>
</member>
- <member name="F:StarSimLib.Graphics.Drawer.farDistance">
+ <member name="M:StarSimLib.Data_Structures.Matrix4x4.#ctor(System.Double)">
<summary>
- The furthest distance that can be seen on the <see cref="T:SFML.Graphics.RenderTarget"/>. Any bodies that are further
- from the camera than this distance are culled and not rendered.
+ Initialises a new instance of the <see cref="T:StarSimLib.Data_Structures.Matrix4x4"/> struct.
</summary>
+ <param name="defaultValue">The value to which to initialise all fields in the matrix.</param>
</member>
- <member name="F:StarSimLib.Graphics.Drawer.fieldOfView">
+ <member name="M:StarSimLib.Data_Structures.Matrix4x4.#ctor(System.Double[][])">
<summary>
- The field of view for the drawer in degrees.
+ Initialises a new instance of the <see cref="T:StarSimLib.Data_Structures.Matrix4x4"/> struct.
</summary>
+ <param name="sourceMatrix">The source matrix from which to copy over values.</param>
</member>
- <member name="F:StarSimLib.Graphics.Drawer.nearDistance">
+ <member name="M:StarSimLib.Data_Structures.Matrix4x4.#ctor(StarSimLib.Data_Structures.Matrix4x4)">
<summary>
- The closest distance that can be seen on the <see cref="T:SFML.Graphics.RenderTarget"/>. Any bodies that are closer
- to the camera than this distance (i.e. behind the camera) are culled and not rendered.
+ Initialises a new instance of the <see cref="T:StarSimLib.Data_Structures.Matrix4x4"/> struct.
</summary>
+ <param name="sourceMatrix">The source matrix from which to copy over values.</param>
</member>
- <member name="F:StarSimLib.Graphics.Drawer.inverseScaleFactor">
+ <member name="M:StarSimLib.Data_Structures.Matrix4x4.#ctor(System.Double[][],StarSimLib.Data_Structures.Matrix4x4.MatrixValueGeneratorDelegate)">
<summary>
- Inverse scale factor used in the projection matrix.
+ Initialises a new instance of the <see cref="T:StarSimLib.Data_Structures.Matrix4x4"/> struct.
</summary>
+ <param name="sourceMatrix">The source matrix.</param>
+ <param name="valueGenerator">
+ The <see cref="T:StarSimLib.Data_Structures.Matrix4x4.MatrixValueGeneratorDelegate"/> to use to generate new matrix values. Can use the source matrix
+ or can ignore it.
+ </param>
</member>
- <member name="F:StarSimLib.Graphics.Drawer.aspectRatio">
+ <member name="M:StarSimLib.Data_Structures.Matrix4x4.#ctor(StarSimLib.Data_Structures.Matrix4x4,StarSimLib.Data_Structures.Matrix4x4.MatrixValueGeneratorDelegate)">
<summary>
- The aspect ratio of the render target. Allows for normalisation of the <see cref="T:SFML.Graphics.RenderTarget"/> space
- into a normal plane ([-1, -1] = top left, [1, 1] = bottom right).
+ Initialises a new instance of the <see cref="T:StarSimLib.Data_Structures.Matrix4x4"/> struct.
</summary>
+ <param name="sourceMatrix">The source matrix.</param>
+ <param name="valueGenerator">
+ The <see cref="T:StarSimLib.Data_Structures.Matrix4x4.MatrixValueGeneratorDelegate"/> to use to generate new matrix values. Can use the source matrix
+ or can ignore it.
+ </param>
</member>
- <member name="F:StarSimLib.Graphics.Drawer.managedBodies">
+ <member name="T:StarSimLib.Data_Structures.Matrix4x4.MatrixValueGeneratorDelegate">
<summary>
- Holds all the <see cref="T:StarSimLib.Physics.Body"/> instances that should be simulated.
+ Generates a value to place in the target matrix (at [i, j]), using a source matrix and i and j coordinates.
</summary>
+ <param name="sourceMatrix">The source matrix to use.</param>
+ <param name="i">The column index.</param>
+ <param name="j">The row index</param>
+ <returns>The value to place at the (i, j) position in the new matrix.</returns>
</member>
- <member name="F:StarSimLib.Graphics.Drawer.managedBodyShapeMap">
+ <member name="P:StarSimLib.Data_Structures.Matrix4x4.Item(System.Int32,System.Int32)">
<summary>
- Maps a <see cref="T:StarSimLib.Physics.Body"/> to the <see cref="T:SFML.Graphics.CircleShape"/> that represents it, and is drawn to the
- screen at the <see cref="T:StarSimLib.Physics.Body"/>s position.
+ Indexes the matrix as a 2D array.
</summary>
+ <param name="i">The column index.</param>
+ <param name="j">The row index.</param>
+ <returns>The value at the specified field.</returns>
</member>
- <member name="F:StarSimLib.Graphics.Drawer.originOffset">
+ <member name="M:StarSimLib.Data_Structures.Matrix4x4.op_Implicit(StarSimLib.Data_Structures.Matrix4x4)~System.Double[][]">
<summary>
- The offset that has to be applied to the positions of a <see cref="T:SFML.Graphics.CircleShape"/>, so that they appear
- to be in the centre of the render target and not the top left corner.
+ Implicitly converts a <see cref="T:StarSimLib.Data_Structures.Matrix4x4"/> to a 2D <see cref="T:System.Double"/> array.
</summary>
+ <param name="matrix4x4">The matrix to convert.</param>
</member>
- <member name="F:StarSimLib.Graphics.Drawer.projectionMatrix">
+ <member name="M:StarSimLib.Data_Structures.Matrix4x4.op_Multiply(StarSimLib.Data_Structures.Matrix4x4,StarSimLib.Data_Structures.Vector4d)">
<summary>
- Projection matrix used for mapping from 3D to 2D.
+ Implements the multiplication operator for a <see cref="T:StarSimLib.Data_Structures.Matrix4x4"/> and a <see cref="T:StarSimLib.Data_Structures.Vector4d"/>. This is
+ the 'dot' operation for a vector and a matrix.
</summary>
+ <param name="matrix4x4">The matrix.</param>
+ <param name="vector">The 3D vector.</param>
+ <returns>The dot product of the <see cref="T:StarSimLib.Data_Structures.Matrix4x4"/> and the <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</returns>
</member>
- <member name="F:StarSimLib.Graphics.Drawer.renderTarget">
+ <member name="M:StarSimLib.Data_Structures.Matrix4x4.op_Multiply(StarSimLib.Data_Structures.Vector4d,StarSimLib.Data_Structures.Matrix4x4)">
<summary>
- The target to which the managed bodies will be drawn.
+ Implements the multiplication operator for a <see cref="T:StarSimLib.Data_Structures.Matrix4x4"/> and a <see cref="T:StarSimLib.Data_Structures.Vector4d"/>. This is
+ the 'dot' operation for a vector and a matrix.
</summary>
+ <param name="vector">The 3D vector.</param>
+ <param name="matrix4x4">The matrix.</param>
+ <returns>The dot product of the <see cref="T:StarSimLib.Data_Structures.Matrix4x4"/> and the <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</returns>
</member>
- <member name="M:StarSimLib.Graphics.Drawer.#ctor(SFML.Graphics.RenderTarget,StarSimLib.Physics.Body[]@,System.Collections.Generic.Dictionary{StarSimLib.Physics.Body,SFML.Graphics.CircleShape}@)">
+ <member name="M:StarSimLib.Data_Structures.Matrix4x4.ToString">
+ <inheritdoc />
+ </member>
+ <member name="T:StarSimLib.Data_Structures.Quaternion">
<summary>
- Initialises a new instance of the <see cref="T:StarSimLib.Graphics.Drawer"/> class.
+ Represents a rotation as a set of 4 values.
</summary>
- <param name="target">The target to which the managed bodies should be rendered.</param>
- <param name="bodies">The <see cref="T:StarSimLib.Physics.Body"/> instances which should be managed by this instance.</param>
- <param name="bodyShapeMap">
- Maps a <see cref="T:StarSimLib.Physics.Body"/> instance to the <see cref="T:SFML.Graphics.CircleShape"/> that represents it, and is drawn to the
- screen at the <see cref="T:StarSimLib.Physics.Body"/> instances position.
- </param>
</member>
- <member name="M:StarSimLib.Graphics.Drawer.DrawBodies">
+ <member name="T:StarSimLib.Data_Structures.Vector4d">
<summary>
- Draws each <see cref="T:StarSimLib.Physics.Body"/> instance that is managed by this drawer to the <see cref="T:SFML.Graphics.RenderTarget"/> specified
- in the constructor.
+ A 4D vector with <see cref="T:System.Double"/> components.
</summary>
</member>
- <member name="M:StarSimLib.Graphics.Drawer.Scale(System.Single)">
+ <member name="F:StarSimLib.Data_Structures.Vector4d.W">
<summary>
- Scales this instances view by the given amount.
+ The w component of the vector.
</summary>
- <param name="scaleMultiplier">The multiplier by which to scale the viewport of this instances render target.</param>
</member>
- <member name="T:StarSimLib.Matrix4x4">
+ <member name="F:StarSimLib.Data_Structures.Vector4d.X">
<summary>
- A 4-by-4 matrix of <see cref="T:System.Double"/> values.
+ The x component of the vector.
</summary>
</member>
- <member name="F:StarSimLib.Matrix4x4.matrix">
+ <member name="F:StarSimLib.Data_Structures.Vector4d.Y">
<summary>
- The internal matrix representation.
+ The y component of the vector.
</summary>
</member>
- <member name="F:StarSimLib.Matrix4x4.CopyMatrixValuesGeneratorDelegate">
+ <member name="F:StarSimLib.Data_Structures.Vector4d.Z">
<summary>
- The default <see cref="T:StarSimLib.Matrix4x4.MatrixValueGeneratorDelegate"/> to use when constructing a <see cref="T:StarSimLib.Matrix4x4"/>
- from a given 2D <see cref="T:System.Double"/> array. Simply copies over the values from the source matrix to the
- output matrix. Should the source matrix contain null fields, a 0 will be placed at the relevant field in
- the target matrix.
+ The z component of the vector.
</summary>
</member>
- <member name="M:StarSimLib.Matrix4x4.#ctor(System.Double)">
+ <member name="M:StarSimLib.Data_Structures.Vector4d.#ctor(System.Double,System.Double)">
<summary>
- Initialises a new instance of the <see cref="T:StarSimLib.Matrix4x4"/> struct.
+ Initialises a new instance of the <see cref="T:StarSimLib.Data_Structures.Vector4d"/> struct. Sets Z and W to 0.
</summary>
- <param name="defaultValue">The value to which to initialise all fields in the matrix.</param>
+ <param name="x">The x component.</param>
+ <param name="y">The y component.</param>
</member>
- <member name="M:StarSimLib.Matrix4x4.#ctor(System.Double[][])">
+ <member name="M:StarSimLib.Data_Structures.Vector4d.#ctor(System.Double,System.Double,System.Double)">
<summary>
- Initialises a new instance of the <see cref="T:StarSimLib.Matrix4x4"/> struct.
+ Initialises a new instance of the <see cref="T:StarSimLib.Data_Structures.Vector4d"/> struct. Sets W to 0.
</summary>
- <param name="sourceMatrix">The source matrix from which to copy over values.</param>
+ <param name="x">The x component.</param>
+ <param name="y">The y component.</param>
+ <param name="z">The z component.</param>
</member>
- <member name="M:StarSimLib.Matrix4x4.#ctor(StarSimLib.Matrix4x4)">
+ <member name="M:StarSimLib.Data_Structures.Vector4d.#ctor(System.Double,System.Double,System.Double,System.Double)">
<summary>
- Initialises a new instance of the <see cref="T:StarSimLib.Matrix4x4"/> struct.
+ Initialises a new instance of the <see cref="T:StarSimLib.Data_Structures.Vector4d"/> struct.
</summary>
- <param name="sourceMatrix">The source matrix from which to copy over values.</param>
+ <param name="x">The x component.</param>
+ <param name="y">The y component.</param>
+ <param name="z">The z component.</param>
+ <param name="w">The w component.</param>
</member>
- <member name="M:StarSimLib.Matrix4x4.#ctor(System.Double[][],StarSimLib.Matrix4x4.MatrixValueGeneratorDelegate)">
+ <member name="M:StarSimLib.Data_Structures.Vector4d.op_Subtraction(StarSimLib.Data_Structures.Vector4d,StarSimLib.Data_Structures.Vector4d)">
<summary>
- Initialises a new instance of the <see cref="T:StarSimLib.Matrix4x4"/> struct.
+ Implements the subtraction operator for 2 <see cref="T:StarSimLib.Data_Structures.Vector4d"/>s.
</summary>
- <param name="sourceMatrix">The source matrix.</param>
- <param name="valueGenerator">
- The <see cref="T:StarSimLib.Matrix4x4.MatrixValueGeneratorDelegate"/> to use to generate new matrix values. Can use the source matrix
- or can ignore it.
- </param>
+ <param name="vector">The original <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</param>
+ <param name="vector2">The other <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</param>
+ <returns>The new <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</returns>
</member>
- <member name="M:StarSimLib.Matrix4x4.#ctor(StarSimLib.Matrix4x4,StarSimLib.Matrix4x4.MatrixValueGeneratorDelegate)">
+ <member name="M:StarSimLib.Data_Structures.Vector4d.op_Subtraction(StarSimLib.Data_Structures.Vector4d,System.ValueTuple{System.Double,System.Double,System.Double,System.Double})">
<summary>
- Initialises a new instance of the <see cref="T:StarSimLib.Matrix4x4"/> struct.
+ Implements the subtraction operator for a <see cref="T:StarSimLib.Data_Structures.Vector4d"/> and a (X, Y, Z, W) tuple.
</summary>
- <param name="sourceMatrix">The source matrix.</param>
- <param name="valueGenerator">
- The <see cref="T:StarSimLib.Matrix4x4.MatrixValueGeneratorDelegate"/> to use to generate new matrix values. Can use the source matrix
- or can ignore it.
- </param>
+ <param name="vector">The original <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</param>
+ <param name="vector2">The 4D tuple.</param>
+ <returns>The new <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</returns>
</member>
- <member name="T:StarSimLib.Matrix4x4.MatrixValueGeneratorDelegate">
+ <member name="M:StarSimLib.Data_Structures.Vector4d.op_Subtraction(System.ValueTuple{System.Double,System.Double,System.Double,System.Double},StarSimLib.Data_Structures.Vector4d)">
<summary>
- Generates a value to place in the target matrix (at [i, j]), using a source matrix and i and j coordinates.
+ Implements the subtraction operator for a <see cref="T:StarSimLib.Data_Structures.Vector4d"/> and a (X, Y, Z, W) tuple.
</summary>
- <param name="sourceMatrix">The source matrix to use.</param>
- <param name="i">The column index.</param>
- <param name="j">The row index</param>
- <returns>The value to place at the (i, j) position in the new matrix.</returns>
+ <param name="vector">The original <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</param>
+ <param name="vector2">The 4D tuple.</param>
+ <returns>The new <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</returns>
</member>
- <member name="P:StarSimLib.Matrix4x4.Item(System.Int32,System.Int32)">
+ <member name="M:StarSimLib.Data_Structures.Vector4d.op_Subtraction(StarSimLib.Data_Structures.Vector4d,System.Double)">
<summary>
- Indexes the matrix as a 2D array.
+ Implements the subtraction operator for a <see cref="T:StarSimLib.Data_Structures.Vector4d"/> and a scalar <see cref="T:System.Double"/> value.
</summary>
- <param name="i">The column index.</param>
- <param name="j">The row index.</param>
- <returns>The value at the specified field.</returns>
+ <param name="vector">The original <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</param>
+ <param name="scalar">The scalar <see cref="T:System.Double"/>.</param>
+ <returns>The new <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</returns>
</member>
- <member name="M:StarSimLib.Matrix4x4.op_Implicit(StarSimLib.Matrix4x4)~System.Double[][]">
+ <member name="M:StarSimLib.Data_Structures.Vector4d.op_Subtraction(System.Double,StarSimLib.Data_Structures.Vector4d)">
<summary>
- Implicitly converts a <see cref="T:StarSimLib.Matrix4x4"/> to a 2D <see cref="T:System.Double"/> array.
+ Implements the subtraction operator for a <see cref="T:StarSimLib.Data_Structures.Vector4d"/> and a scalar <see cref="T:System.Double"/> value.
</summary>
- <param name="matrix4x4">The matrix to convert.</param>
+ <param name="vector">The original <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</param>
+ <param name="scalar">The scalar <see cref="T:System.Double"/>.</param>
+ <returns>The new <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</returns>
</member>
- <member name="M:StarSimLib.Matrix4x4.op_Multiply(StarSimLib.Matrix4x4,StarSimLib.Vector4d)">
+ <member name="M:StarSimLib.Data_Structures.Vector4d.op_Multiply(StarSimLib.Data_Structures.Vector4d,StarSimLib.Data_Structures.Vector4d)">
<summary>
- Implements the multiplication operator for a <see cref="T:StarSimLib.Matrix4x4"/> and a <see cref="T:StarSimLib.Vector4d"/>. This is
- the 'dot' operation for a vector and a matrix.
+ Implements the multiplication operator for 2 <see cref="T:StarSimLib.Data_Structures.Vector4d"/>s.
</summary>
- <param name="matrix4x4">The matrix.</param>
- <param name="vector">The 3D vector.</param>
- <returns>The dot product of the <see cref="T:StarSimLib.Matrix4x4"/> and the <see cref="T:StarSimLib.Vector4d"/>.</returns>
+ <param name="vector">The original <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</param>
+ <param name="vector2">The other <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</param>
+ <returns>The new <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</returns>
</member>
- <member name="M:StarSimLib.Matrix4x4.op_Multiply(StarSimLib.Vector4d,StarSimLib.Matrix4x4)">
+ <member name="M:StarSimLib.Data_Structures.Vector4d.op_Multiply(StarSimLib.Data_Structures.Vector4d,System.ValueTuple{System.Double,System.Double,System.Double,System.Double})">
<summary>
- Implements the multiplication operator for a <see cref="T:StarSimLib.Matrix4x4"/> and a <see cref="T:StarSimLib.Vector4d"/>. This is
- the 'dot' operation for a vector and a matrix.
+ Implements the multiplication operator for a <see cref="T:StarSimLib.Data_Structures.Vector4d"/> and a (X, Y, Z, W) tuple.
</summary>
- <param name="vector">The 3D vector.</param>
- <param name="matrix4x4">The matrix.</param>
- <returns>The dot product of the <see cref="T:StarSimLib.Matrix4x4"/> and the <see cref="T:StarSimLib.Vector4d"/>.</returns>
+ <param name="vector">The original <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</param>
+ <param name="vector2">The 4D tuple.</param>
+ <returns>The new <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</returns>
</member>
- <member name="M:StarSimLib.Matrix4x4.ToString">
- <inheritdoc />
+ <member name="M:StarSimLib.Data_Structures.Vector4d.op_Multiply(System.ValueTuple{System.Double,System.Double,System.Double,System.Double},StarSimLib.Data_Structures.Vector4d)">
+ <summary>
+ Implements the multiplication operator for a <see cref="T:StarSimLib.Data_Structures.Vector4d"/> and a (X, Y, Z, W) tuple.
+ </summary>
+ <param name="vector">The original <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</param>
+ <param name="vector2">The 4D tuple.</param>
+ <returns>The new <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</returns>
</member>
- <member name="T:StarSimLib.Physics.Body">
+ <member name="M:StarSimLib.Data_Structures.Vector4d.op_Multiply(StarSimLib.Data_Structures.Vector4d,System.Double)">
<summary>
- Represents a stellar body.
+ Implements the multiplication operator for a <see cref="T:StarSimLib.Data_Structures.Vector4d"/> and a scalar <see cref="T:System.Double"/> value.
</summary>
+ <param name="vector">The original <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</param>
+ <param name="scalar">The scalar <see cref="T:System.Double"/>.</param>
+ <returns>The new <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</returns>
</member>
- <member name="F:StarSimLib.Physics.Body.BodyFormatString">
+ <member name="M:StarSimLib.Data_Structures.Vector4d.op_Multiply(System.Double,StarSimLib.Data_Structures.Vector4d)">
<summary>
- Describes how the <see cref="T:StarSimLib.Physics.Body"/> instance should be formatted as a <see cref="T:System.String"/>.
+ Implements the multiplication operator for a <see cref="T:StarSimLib.Data_Structures.Vector4d"/> and a scalar <see cref="T:System.Double"/> value.
</summary>
+ <param name="vector">The original <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</param>
+ <param name="scalar">The scalar <see cref="T:System.Double"/>.</param>
+ <returns>The new <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</returns>
</member>
- <member name="F:StarSimLib.Physics.Body.force">
+ <member name="M:StarSimLib.Data_Structures.Vector4d.op_Division(StarSimLib.Data_Structures.Vector4d,StarSimLib.Data_Structures.Vector4d)">
<summary>
- The backing field for the <see cref="P:StarSimLib.Physics.Body.Force"/> property.
+ Implements the division operator for 2 <see cref="T:StarSimLib.Data_Structures.Vector4d"/>s.
</summary>
+ <param name="vector">The original <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</param>
+ <param name="vector2">The other <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</param>
+ <returns>The new <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</returns>
</member>
- <member name="F:StarSimLib.Physics.Body.mass">
+ <member name="M:StarSimLib.Data_Structures.Vector4d.op_Division(StarSimLib.Data_Structures.Vector4d,System.ValueTuple{System.Double,System.Double,System.Double,System.Double})">
<summary>
- Backing field for the <see cref="P:StarSimLib.Physics.Body.Mass"/> property.
+ Implements the division operator for a <see cref="T:StarSimLib.Data_Structures.Vector4d"/> and a (X, Y, Z, W) tuple.
</summary>
+ <param name="vector">The original <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</param>
+ <param name="vector2">The 4D tuple.</param>
+ <returns>The new <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</returns>
</member>
- <member name="F:StarSimLib.Physics.Body.position">
+ <member name="M:StarSimLib.Data_Structures.Vector4d.op_Division(System.ValueTuple{System.Double,System.Double,System.Double,System.Double},StarSimLib.Data_Structures.Vector4d)">
<summary>
- Backing field for the <see cref="P:StarSimLib.Physics.Body.Position"/> property.
+ Implements the division operator for a <see cref="T:StarSimLib.Data_Structures.Vector4d"/> and a (X, Y, Z, W) tuple.
</summary>
+ <param name="vector">The original <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</param>
+ <param name="vector2">The 4D tuple.</param>
+ <returns>The new <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</returns>
</member>
- <member name="F:StarSimLib.Physics.Body.velocity">
+ <member name="M:StarSimLib.Data_Structures.Vector4d.op_Division(StarSimLib.Data_Structures.Vector4d,System.Double)">
<summary>
- Backing field for the <see cref="P:StarSimLib.Physics.Body.Velocity"/> property.
+ Implements the division operator for a <see cref="T:StarSimLib.Data_Structures.Vector4d"/> and a scalar <see cref="T:System.Double"/> value.
</summary>
+ <param name="vector">The original <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</param>
+ <param name="scalar">The scalar <see cref="T:System.Double"/>.</param>
+ <returns>The new <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</returns>
</member>
- <member name="F:StarSimLib.Physics.Body.Generation">
+ <member name="M:StarSimLib.Data_Structures.Vector4d.op_Division(System.Double,StarSimLib.Data_Structures.Vector4d)">
<summary>
- The generation that this body belongs to.
+ Implements the division operator for a <see cref="T:StarSimLib.Data_Structures.Vector4d"/> and a scalar <see cref="T:System.Double"/> value.
</summary>
+ <param name="vector">The original <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</param>
+ <param name="scalar">The scalar <see cref="T:System.Double"/>.</param>
+ <returns>The new <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</returns>
</member>
- <member name="F:StarSimLib.Physics.Body.Id">
+ <member name="M:StarSimLib.Data_Structures.Vector4d.op_Addition(StarSimLib.Data_Structures.Vector4d,StarSimLib.Data_Structures.Vector4d)">
<summary>
- The unique id for this body.
+ Implements the addition operator for 2 <see cref="T:StarSimLib.Data_Structures.Vector4d"/>s.
</summary>
+ <param name="vector">The original <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</param>
+ <param name="vector2">The other <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</param>
+ <returns>The new <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</returns>
</member>
- <member name="M:StarSimLib.Physics.Body.#ctor(StarSimLib.Vector4d,StarSimLib.Vector4d,System.Double,System.UInt32,System.UInt32)">
+ <member name="M:StarSimLib.Data_Structures.Vector4d.op_Addition(StarSimLib.Data_Structures.Vector4d,System.ValueTuple{System.Double,System.Double,System.Double,System.Double})">
<summary>
- Initialises a new instance of the <see cref="T:StarSimLib.Physics.Body"/> class.
+ Implements the addition operator for a <see cref="T:StarSimLib.Data_Structures.Vector4d"/> and a (X, Y, Z, W) tuple.
</summary>
- <param name="position">The starting position of the <see cref="T:StarSimLib.Physics.Body"/>.</param>
- <param name="velocity">The starting velocity of the <see cref="T:StarSimLib.Physics.Body"/>.</param>
- <param name="mass">The starting mass of the <see cref="T:StarSimLib.Physics.Body"/>.</param>
- <param name="generation">The generation that this <see cref="T:StarSimLib.Physics.Body"/> belongs to.</param>
- <param name="id">The unique id for this body.</param>
+ <param name="vector">The original <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</param>
+ <param name="vector2">The 4D tuple.</param>
+ <returns>The new <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</returns>
</member>
- <member name="P:StarSimLib.Physics.Body.Force">
+ <member name="M:StarSimLib.Data_Structures.Vector4d.op_Addition(System.ValueTuple{System.Double,System.Double,System.Double,System.Double},StarSimLib.Data_Structures.Vector4d)">
<summary>
- The current force on the <see cref="T:StarSimLib.Physics.Body"/> in 3D space.
+ Implements the addition operator for a <see cref="T:StarSimLib.Data_Structures.Vector4d"/> and a (X, Y, Z, W) tuple.
</summary>
+ <param name="vector">The original <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</param>
+ <param name="vector2">The 4D tuple.</param>
+ <returns>The new <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</returns>
</member>
- <member name="P:StarSimLib.Physics.Body.Mass">
+ <member name="M:StarSimLib.Data_Structures.Vector4d.op_Addition(StarSimLib.Data_Structures.Vector4d,System.Double)">
<summary>
- The mass of the <see cref="T:StarSimLib.Physics.Body"/>.
+ Implements the addition operator for a <see cref="T:StarSimLib.Data_Structures.Vector4d"/> and a scalar <see cref="T:System.Double"/> value.
</summary>
+ <param name="vector">The original <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</param>
+ <param name="scalar">The scalar <see cref="T:System.Double"/>.</param>
+ <returns>The new <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</returns>
</member>
- <member name="P:StarSimLib.Physics.Body.Position">
+ <member name="M:StarSimLib.Data_Structures.Vector4d.op_Addition(System.Double,StarSimLib.Data_Structures.Vector4d)">
<summary>
- The current position of the <see cref="T:StarSimLib.Physics.Body"/> in 3D space.
+ Implements the addition operator for a <see cref="T:StarSimLib.Data_Structures.Vector4d"/> and a scalar <see cref="T:System.Double"/> value.
</summary>
+ <param name="vector">The original <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</param>
+ <param name="scalar">The scalar <see cref="T:System.Double"/>.</param>
+ <returns>The new <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.</returns>
</member>
- <member name="P:StarSimLib.Physics.Body.Velocity">
+ <member name="P:StarSimLib.Data_Structures.Vector4d.Item(System.Int32)">
<summary>
- The current velocity of the <see cref="T:StarSimLib.Physics.Body"/> in 3D space.
+ Indexes the vector as a 1D array.
</summary>
+ <param name="i">The column index.</param>
+ <returns>The value at the specified field.</returns>
</member>
- <member name="M:StarSimLib.Physics.Body.GetForceBetween(StarSimLib.Physics.Body,StarSimLib.Physics.Body)">
+ <member name="M:StarSimLib.Data_Structures.Vector4d.Abs">
<summary>
- Gets the force vector for the attraction between <see cref="T:StarSimLib.Physics.Body"/> A and <see cref="T:StarSimLib.Physics.Body"/> B.
+ Returns the absolute value of this <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.
</summary>
- <param name="a">The first <see cref="T:StarSimLib.Physics.Body"/> instance.</param>
- <param name="b">The second <see cref="T:StarSimLib.Physics.Body"/> instance.</param>
- <returns></returns>
+ <returns>The absolute value (magnitude) of this <see cref="T:StarSimLib.Data_Structures.Vector4d"/>, as a <see cref="T:System.Double"/>.</returns>
</member>
- <member name="M:StarSimLib.Physics.Body.AddForce(StarSimLib.Physics.Body)">
+ <member name="M:StarSimLib.Data_Structures.Vector4d.Magnitude">
<summary>
- Calculates the force between this instance and the given other body, and adds the resultant vector to the
- internal total force vector.
+ Returns the magnitude of this <see cref="T:StarSimLib.Data_Structures.Vector4d"/>.
</summary>
- <param name="otherBody">The other body to calculate the force between.</param>
+ <returns>The magnitude (absolute value) of this <see cref="T:StarSimLib.Data_Structures.Vector4d"/>, as a <see cref="T:System.Double"/>.</returns>
</member>
- <member name="M:StarSimLib.Physics.Body.Collide(StarSimLib.Physics.Body)">
+ <member name="T:StarSimLib.Data_Structures.Vector4d.UnitVectors">
<summary>
- Collides this instance with the given <see cref="T:StarSimLib.Physics.Body"/> instance.
+ Holds unit vectors.
</summary>
- <param name="otherBody">The other instance with which to collide.</param>
</member>
- <member name="M:StarSimLib.Physics.Body.DistanceTo(StarSimLib.Physics.Body,StarSimLib.Vector4d@)">
+ <member name="F:StarSimLib.Data_Structures.Vector4d.UnitVectors.Backwards">
<summary>
- Finds and returns the distance between the current <see cref="T:StarSimLib.Physics.Body"/> instance and the given <see cref="T:StarSimLib.Physics.Body"/>.
- In other words, it finds the magnitude of the translation vector between the two <see cref="T:StarSimLib.Physics.Body"/> instances.
+ The negative unit vector for the Z axis.
</summary>
- <param name="body">The other <see cref="T:StarSimLib.Physics.Body"/> instance to which to calculate the distance.</param>
- <param name="displacement">The vector showing the displacement of the current body from the given one.</param>
- <returns>The distance to the other <see cref="T:StarSimLib.Physics.Body"/> as a <see cref="T:System.Single"/>.</returns>
</member>
- <member name="M:StarSimLib.Physics.Body.ResetForce">
+ <member name="F:StarSimLib.Data_Structures.Vector4d.UnitVectors.Down">
<summary>
- Resets the internal force vector.
+ The negative unit vector for the Y axis.
</summary>
</member>
- <member name="M:StarSimLib.Physics.Body.Update(System.Double)">
+ <member name="F:StarSimLib.Data_Structures.Vector4d.UnitVectors.Forwards">
<summary>
- Updates the <see cref="P:StarSimLib.Physics.Body.Position"/> of the current body using the internal force vector and the given time step.
+ The positive unit vector for the Z axis.
</summary>
- <param name="deltaTime">The time step.</param>
</member>
- <member name="M:StarSimLib.Physics.Body.Update(StarSimLib.Vector4d,System.Double)">
+ <member name="F:StarSimLib.Data_Structures.Vector4d.UnitVectors.Left">
<summary>
- Updates the <see cref="P:StarSimLib.Physics.Body.Position"/> of the current body using the given force vector and time step.
+ The positive unit vector for the X axis.
</summary>
- <param name="forceVector">The sum vector of all forces due to other <see cref="T:StarSimLib.Physics.Body"/>s.</param>
- <param name="deltaTime">The time step.</param>
</member>
- <member name="M:StarSimLib.Physics.Body.ToString">
+ <member name="F:StarSimLib.Data_Structures.Vector4d.UnitVectors.Right">
+ <summary>
+ The negative unit vector for the X axis.
+ </summary>
+ </member>
+ <member name="F:StarSimLib.Data_Structures.Vector4d.UnitVectors.Up">
+ <summary>
+ The positive unit vector for the Y axis.
+ </summary>
+ </member>
+ <member name="M:StarSimLib.Data_Structures.Vector4d.ToString">
<inheritdoc />
</member>
- <member name="T:StarSimLib.Physics.BodyGenerator">
+ <member name="T:StarSimLib.Extensions.Vector3fExtensions">
<summary>
- Provides methods for generating <see cref="T:StarSimLib.Physics.Body"/> instances.
+ Provides additional functionality to the <see cref="T:SFML.System.Vector3f"/> struct.
</summary>
</member>
- <member name="F:StarSimLib.Physics.BodyGenerator.Rng">
+ <member name="M:StarSimLib.Extensions.Vector3fExtensions.Magnitude(SFML.System.Vector3f)">
<summary>
- Caches a random number generator to use for all randomised positions and velocities.
+ Returns the magnitude of the given <see cref="T:SFML.System.Vector3f"/>.
</summary>
+ <param name="vector">The vector whose magnitude to return.</param>
+ <returns>The magnitude of the given <see cref="T:SFML.System.Vector3f"/>.</returns>
</member>
- <member name="P:StarSimLib.Physics.BodyGenerator.CurrentGeneration">
+ <member name="T:StarSimLib.Graphics.RotationDirection">
<summary>
- The current generation of <see cref="T:StarSimLib.Physics.Body"/> instances that the generator is on.
+ Enumerates all possible rotation directions (i.e. north, east, south, west, clockwise, anticlockwise).
</summary>
</member>
- <member name="M:StarSimLib.Physics.BodyGenerator.GenerateBodies(System.Int32,System.Boolean)">
+ <member name="F:StarSimLib.Graphics.RotationDirection.North">
<summary>
- Generates an array of <see cref="T:StarSimLib.Physics.Body"/> instances, possibly including a central attractor.
+ Represents an anticlockwise rotation in the x-axis.
</summary>
- <param name="bodyCount">The number of <see cref="T:StarSimLib.Physics.Body"/> instances to generate.</param>
- <param name="centralAttractor">Whether to have a central massive attractor.</param>
- <returns>The generated <see cref="T:StarSimLib.Physics.Body"/> array.</returns>
</member>
- <member name="M:StarSimLib.Physics.BodyGenerator.GenerateShapes(System.Collections.Generic.IEnumerable{StarSimLib.Physics.Body})">
+ <member name="F:StarSimLib.Graphics.RotationDirection.East">
<summary>
- Generates a <see cref="T:System.Collections.Generic.Dictionary`2"/> mapping each given <see cref="T:StarSimLib.Physics.Body"/> to a
- <see cref="T:SFML.Graphics.CircleShape"/> that represents the body instance in 2D space.
+ Represents an anticlockwise rotation in the y-axis.
</summary>
- <param name="bodies">The <see cref="T:StarSimLib.Physics.Body"/> instances for which to generate the shapes.</param>
- <returns>
- A <see cref="T:System.Collections.Generic.Dictionary`2"/> mapping the given <see cref="T:StarSimLib.Physics.Body"/> instances to their <see cref="T:SFML.Graphics.CircleShape"/> instances.
- </returns>
</member>
- <member name="T:StarSimLib.Physics.UpdateDelegate">
+ <member name="F:StarSimLib.Graphics.RotationDirection.South">
<summary>
- Updates the given <see cref="T:StarSimLib.Physics.Body"/> collections individual bodies, using the given delta time.
+ Represents a clockwise rotation in the x-axis.
</summary>
- <param name="bodies">The body collection.</param>
- <param name="deltaTime">The time step.</param>
</member>
- <member name="T:StarSimLib.Physics.BodyUpdater">
+ <member name="F:StarSimLib.Graphics.RotationDirection.West">
<summary>
- Provides methods for updating <see cref="T:StarSimLib.Physics.Body"/> instance positions.
+ Represents a clockwise rotation in the y-axis.
</summary>
</member>
- <member name="M:StarSimLib.Physics.BodyUpdater.UpdateBodiesBruteForce(System.Collections.Generic.IEnumerable{StarSimLib.Physics.Body},System.Double)">
+ <member name="F:StarSimLib.Graphics.RotationDirection.Clockwise">
<summary>
- Updates the positions of all the given <see cref="T:StarSimLib.Physics.Body"/>s with O(n^2) time complexity, with the given time step.
+ Represents a clockwise rotation in the z-axis.
</summary>
- <param name="bodies">The collection of <see cref="T:StarSimLib.Physics.Body"/>s whose positions to update.</param>
- <param name="deltaTime">The time step.</param>
</member>
- <member name="T:StarSimLib.Physics.OrbitGenerator">
+ <member name="F:StarSimLib.Graphics.RotationDirection.Anticlockwise">
<summary>
- Provides methods for initialising positions, velocities, and orbits for <see cref="T:StarSimLib.Physics.Body"/> instances.
+ Represents an anticlockwise rotation in the z-axis.
</summary>
</member>
- <member name="F:StarSimLib.Physics.OrbitGenerator.Rng">
+ <member name="T:StarSimLib.Graphics.Drawer">
<summary>
- Random number generator.
+ Represents a drawer capable of rendering bodies to a <see cref="T:SFML.Graphics.RenderTarget"/>.
</summary>
</member>
- <member name="M:StarSimLib.Physics.OrbitGenerator.RandomOrbit(StarSimLib.Vector4d)">
+ <member name="F:StarSimLib.Graphics.Drawer.DegToRad">
<summary>
- Returns a randomised orbit around a central, heavy mass.
+ Conversion from degrees to radians, as used by the <see cref="T:System.Math"/> functions.
</summary>
- <param name="positionVector">The position vector for the body for which to generate the orbit.</param>
- <returns>The magnitude of the velocity of the orbit.</returns>
</member>
- <member name="M:StarSimLib.Physics.OrbitGenerator.RandomPosition">
+ <member name="F:StarSimLib.Graphics.Drawer.FarDistance">
<summary>
- Returns a random position within the universe sphere (see <see cref="F:StarSimLib.Constants.UniverseSize"/>).
+ The furthest distance that can be seen on the <see cref="T:SFML.Graphics.RenderTarget"/>. Any bodies that are further
+ from the camera than this distance are culled and not rendered.
</summary>
- <returns>A 3D position vector.</returns>
</member>
- <member name="T:StarSimLib.Vector4d">
+ <member name="F:StarSimLib.Graphics.Drawer.FieldOfView">
<summary>
- A 4D vector with <see cref="T:System.Double"/> components.
+ The default field of view for the drawer in degrees.
</summary>
</member>
- <member name="F:StarSimLib.Vector4d.W">
+ <member name="F:StarSimLib.Graphics.Drawer.NearDistance">
<summary>
- The w component of the vector.
+ The closest distance that can be seen on the <see cref="T:SFML.Graphics.RenderTarget"/>. Any bodies that are closer
+ to the camera than this distance (i.e. behind the camera) are culled and not rendered.
</summary>
</member>
- <member name="F:StarSimLib.Vector4d.X">
+ <member name="F:StarSimLib.Graphics.Drawer.aspectRatio">
<summary>
- The x component of the vector.
+ The aspect ratio of the render target. Allows for normalisation of the <see cref="T:SFML.Graphics.RenderTarget"/> space
+ into a normal plane ([-1, -1] = top left, [1, 1] = bottom right), instead of having to deal with a
+ variable render space.
</summary>
</member>
- <member name="F:StarSimLib.Vector4d.Y">
+ <member name="F:StarSimLib.Graphics.Drawer.managedBodies">
<summary>
- The y component of the vector.
+ Holds all the <see cref="T:StarSimLib.Physics.Body"/> instances that should be simulated.
</summary>
</member>
- <member name="F:StarSimLib.Vector4d.Z">
+ <member name="F:StarSimLib.Graphics.Drawer.managedBodyShapeMap">
<summary>
- The z component of the vector.
+ Maps a <see cref="T:StarSimLib.Physics.Body"/> to the <see cref="T:SFML.Graphics.CircleShape"/> that represents it, and is drawn to the
+ screen at the <see cref="T:StarSimLib.Physics.Body"/>s position.
</summary>
</member>
- <member name="M:StarSimLib.Vector4d.#ctor(System.Double,System.Double)">
+ <member name="F:StarSimLib.Graphics.Drawer.originOffset">
<summary>
- Initialises a new instance of the <see cref="T:StarSimLib.Vector4d"/> struct. Sets Z and W to 0.
+ The offset that has to be applied to the positions of a <see cref="T:SFML.Graphics.CircleShape"/>, so that they appear
+ to be in the centre of the render target and not the top left corner.
</summary>
- <param name="x">The x component.</param>
- <param name="y">The y component.</param>
</member>
- <member name="M:StarSimLib.Vector4d.#ctor(System.Double,System.Double,System.Double)">
+ <member name="F:StarSimLib.Graphics.Drawer.renderTarget">
<summary>
- Initialises a new instance of the <see cref="T:StarSimLib.Vector4d"/> struct. Sets W to 0.
+ The target to which the managed bodies will be drawn.
</summary>
- <param name="x">The x component.</param>
- <param name="y">The y component.</param>
- <param name="z">The z component.</param>
</member>
- <member name="M:StarSimLib.Vector4d.#ctor(System.Double,System.Double,System.Double,System.Double)">
+ <member name="F:StarSimLib.Graphics.Drawer.currentFieldOfView">
<summary>
- Initialises a new instance of the <see cref="T:StarSimLib.Vector4d"/> struct.
+ The current value for the field of view, in degrees. Used to zoom the view in and out.
</summary>
- <param name="x">The x component.</param>
- <param name="y">The y component.</param>
- <param name="z">The z component.</param>
- <param name="w">The w component.</param>
</member>
- <member name="M:StarSimLib.Vector4d.op_Subtraction(StarSimLib.Vector4d,StarSimLib.Vector4d)">
+ <member name="F:StarSimLib.Graphics.Drawer.projectionMatrix">
<summary>
- Implements the subtraction operator for 2 <see cref="T:StarSimLib.Vector4d"/>s.
+ Projection matrix used for mapping from 3D to 2D.
</summary>
- <param name="vector">The original <see cref="T:StarSimLib.Vector4d"/>.</param>
- <param name="vector2">The other <see cref="T:StarSimLib.Vector4d"/>.</param>
- <returns>The new <see cref="T:StarSimLib.Vector4d"/>.</returns>
</member>
- <member name="M:StarSimLib.Vector4d.op_Subtraction(StarSimLib.Vector4d,System.ValueTuple{System.Double,System.Double,System.Double,System.Double})">
+ <member name="F:StarSimLib.Graphics.Drawer.xAngle">
<summary>
- Implements the subtraction operator for a <see cref="T:StarSimLib.Vector4d"/> and a (X, Y, Z, W) tuple.
+ Angle of rotation in the x axis.
</summary>
- <param name="vector">The original <see cref="T:StarSimLib.Vector4d"/>.</param>
- <param name="vector2">The 4D tuple.</param>
- <returns>The new <see cref="T:StarSimLib.Vector4d"/>.</returns>
</member>
- <member name="M:StarSimLib.Vector4d.op_Subtraction(System.ValueTuple{System.Double,System.Double,System.Double,System.Double},StarSimLib.Vector4d)">
+ <member name="F:StarSimLib.Graphics.Drawer.xRotationMatrix">
<summary>
- Implements the subtraction operator for a <see cref="T:StarSimLib.Vector4d"/> and a (X, Y, Z, W) tuple.
+ The rotation matrix for the x axis.
</summary>
- <param name="vector">The original <see cref="T:StarSimLib.Vector4d"/>.</param>
- <param name="vector2">The 4D tuple.</param>
- <returns>The new <see cref="T:StarSimLib.Vector4d"/>.</returns>
</member>
- <member name="M:StarSimLib.Vector4d.op_Subtraction(StarSimLib.Vector4d,System.Double)">
+ <member name="F:StarSimLib.Graphics.Drawer.yAngle">
<summary>
- Implements the subtraction operator for a <see cref="T:StarSimLib.Vector4d"/> and a scalar <see cref="T:System.Double"/> value.
+ Angle of rotation in the y axis.
</summary>
- <param name="vector">The original <see cref="T:StarSimLib.Vector4d"/>.</param>
- <param name="scalar">The scalar <see cref="T:System.Double"/>.</param>
- <returns>The new <see cref="T:StarSimLib.Vector4d"/>.</returns>
</member>
- <member name="M:StarSimLib.Vector4d.op_Subtraction(System.Double,StarSimLib.Vector4d)">
+ <member name="F:StarSimLib.Graphics.Drawer.yRotationMatrix">
<summary>
- Implements the subtraction operator for a <see cref="T:StarSimLib.Vector4d"/> and a scalar <see cref="T:System.Double"/> value.
+ The rotation matrix for the y axis.
</summary>
- <param name="vector">The original <see cref="T:StarSimLib.Vector4d"/>.</param>
- <param name="scalar">The scalar <see cref="T:System.Double"/>.</param>
- <returns>The new <see cref="T:StarSimLib.Vector4d"/>.</returns>
</member>
- <member name="M:StarSimLib.Vector4d.op_Multiply(StarSimLib.Vector4d,StarSimLib.Vector4d)">
+ <member name="F:StarSimLib.Graphics.Drawer.zAngle">
<summary>
- Implements the multiplication operator for 2 <see cref="T:StarSimLib.Vector4d"/>s.
+ Angle of rotation in the z axis.
</summary>
- <param name="vector">The original <see cref="T:StarSimLib.Vector4d"/>.</param>
- <param name="vector2">The other <see cref="T:StarSimLib.Vector4d"/>.</param>
- <returns>The new <see cref="T:StarSimLib.Vector4d"/>.</returns>
</member>
- <member name="M:StarSimLib.Vector4d.op_Multiply(StarSimLib.Vector4d,System.ValueTuple{System.Double,System.Double,System.Double,System.Double})">
+ <member name="F:StarSimLib.Graphics.Drawer.zRotationMatrix">
<summary>
- Implements the multiplication operator for a <see cref="T:StarSimLib.Vector4d"/> and a (X, Y, Z, W) tuple.
+ The rotation matrix for the z axis.
</summary>
- <param name="vector">The original <see cref="T:StarSimLib.Vector4d"/>.</param>
- <param name="vector2">The 4D tuple.</param>
- <returns>The new <see cref="T:StarSimLib.Vector4d"/>.</returns>
</member>
- <member name="M:StarSimLib.Vector4d.op_Multiply(System.ValueTuple{System.Double,System.Double,System.Double,System.Double},StarSimLib.Vector4d)">
+ <member name="M:StarSimLib.Graphics.Drawer.#ctor(SFML.Graphics.RenderTarget,StarSimLib.Physics.Body[]@,System.Collections.Generic.Dictionary{StarSimLib.Physics.Body,SFML.Graphics.CircleShape}@)">
<summary>
- Implements the multiplication operator for a <see cref="T:StarSimLib.Vector4d"/> and a (X, Y, Z, W) tuple.
+ Initialises a new instance of the <see cref="T:StarSimLib.Graphics.Drawer"/> class.
</summary>
- <param name="vector">The original <see cref="T:StarSimLib.Vector4d"/>.</param>
- <param name="vector2">The 4D tuple.</param>
- <returns>The new <see cref="T:StarSimLib.Vector4d"/>.</returns>
+ <param name="target">The target to which the managed bodies should be rendered.</param>
+ <param name="bodies">
+ A reference to the <see cref="T:StarSimLib.Physics.Body"/> instances which should be managed by this instance.
+ </param>
+ <param name="bodyShapeMap">
+ A reference to the dictionary mapping a <see cref="T:StarSimLib.Physics.Body"/> instance to the <see cref="T:SFML.Graphics.CircleShape"/> that
+ represents it, and is drawn to the screen at the <see cref="T:StarSimLib.Physics.Body"/> instance's position.
+ </param>
</member>
- <member name="M:StarSimLib.Vector4d.op_Multiply(StarSimLib.Vector4d,System.Double)">
+ <member name="P:StarSimLib.Graphics.Drawer.InverseScaleFactor">
<summary>
- Implements the multiplication operator for a <see cref="T:StarSimLib.Vector4d"/> and a scalar <see cref="T:System.Double"/> value.
+ Inverse scale factor used in the projection matrix.
</summary>
- <param name="vector">The original <see cref="T:StarSimLib.Vector4d"/>.</param>
- <param name="scalar">The scalar <see cref="T:System.Double"/>.</param>
- <returns>The new <see cref="T:StarSimLib.Vector4d"/>.</returns>
</member>
- <member name="M:StarSimLib.Vector4d.op_Multiply(System.Double,StarSimLib.Vector4d)">
+ <member name="P:StarSimLib.Graphics.Drawer.XAngle">
<summary>
- Implements the multiplication operator for a <see cref="T:StarSimLib.Vector4d"/> and a scalar <see cref="T:System.Double"/> value.
+ Current angle of rotation in the x axis.
</summary>
- <param name="vector">The original <see cref="T:StarSimLib.Vector4d"/>.</param>
- <param name="scalar">The scalar <see cref="T:System.Double"/>.</param>
- <returns>The new <see cref="T:StarSimLib.Vector4d"/>.</returns>
</member>
- <member name="M:StarSimLib.Vector4d.op_Division(StarSimLib.Vector4d,StarSimLib.Vector4d)">
+ <member name="P:StarSimLib.Graphics.Drawer.YAngle">
<summary>
- Implements the division operator for 2 <see cref="T:StarSimLib.Vector4d"/>s.
+ Current angle of rotation in the x axis.
</summary>
- <param name="vector">The original <see cref="T:StarSimLib.Vector4d"/>.</param>
- <param name="vector2">The other <see cref="T:StarSimLib.Vector4d"/>.</param>
- <returns>The new <see cref="T:StarSimLib.Vector4d"/>.</returns>
</member>
- <member name="M:StarSimLib.Vector4d.op_Division(StarSimLib.Vector4d,System.ValueTuple{System.Double,System.Double,System.Double,System.Double})">
+ <member name="P:StarSimLib.Graphics.Drawer.ZAngle">
<summary>
- Implements the division operator for a <see cref="T:StarSimLib.Vector4d"/> and a (X, Y, Z, W) tuple.
+ Current angle of rotation in the x axis.
</summary>
- <param name="vector">The original <see cref="T:StarSimLib.Vector4d"/>.</param>
- <param name="vector2">The 4D tuple.</param>
- <returns>The new <see cref="T:StarSimLib.Vector4d"/>.</returns>
</member>
- <member name="M:StarSimLib.Vector4d.op_Division(System.ValueTuple{System.Double,System.Double,System.Double,System.Double},StarSimLib.Vector4d)">
+ <member name="M:StarSimLib.Graphics.Drawer.UpdateRotationMatrices">
<summary>
- Implements the division operator for a <see cref="T:StarSimLib.Vector4d"/> and a (X, Y, Z, W) tuple.
+ Updates the rotation matrices for the view.
</summary>
- <param name="vector">The original <see cref="T:StarSimLib.Vector4d"/>.</param>
- <param name="vector2">The 4D tuple.</param>
- <returns>The new <see cref="T:StarSimLib.Vector4d"/>.</returns>
</member>
- <member name="M:StarSimLib.Vector4d.op_Division(StarSimLib.Vector4d,System.Double)">
+ <member name="M:StarSimLib.Graphics.Drawer.DrawBodies">
<summary>
- Implements the division operator for a <see cref="T:StarSimLib.Vector4d"/> and a scalar <see cref="T:System.Double"/> value.
+ Draws each <see cref="T:StarSimLib.Physics.Body"/> instance that is managed by this drawer to the <see cref="T:SFML.Graphics.RenderTarget"/> specified
+ in the constructor.
</summary>
- <param name="vector">The original <see cref="T:StarSimLib.Vector4d"/>.</param>
- <param name="scalar">The scalar <see cref="T:System.Double"/>.</param>
- <returns>The new <see cref="T:StarSimLib.Vector4d"/>.</returns>
</member>
- <member name="M:StarSimLib.Vector4d.op_Division(System.Double,StarSimLib.Vector4d)">
+ <member name="M:StarSimLib.Graphics.Drawer.Rotate(StarSimLib.Graphics.RotationDirection,System.Double)">
<summary>
- Implements the division operator for a <see cref="T:StarSimLib.Vector4d"/> and a scalar <see cref="T:System.Double"/> value.
+ Rotates the view in the given direction, by the specified angle (in degrees).
</summary>
- <param name="vector">The original <see cref="T:StarSimLib.Vector4d"/>.</param>
- <param name="scalar">The scalar <see cref="T:System.Double"/>.</param>
- <returns>The new <see cref="T:StarSimLib.Vector4d"/>.</returns>
+ <param name="direction">The direction in which to rotate the view.</param>
+ <param name="angle">The angle by which to rotate in the given direction.</param>
</member>
- <member name="M:StarSimLib.Vector4d.op_Addition(StarSimLib.Vector4d,StarSimLib.Vector4d)">
+ <member name="M:StarSimLib.Graphics.Drawer.Scale(System.Double)">
<summary>
- Implements the addition operator for 2 <see cref="T:StarSimLib.Vector4d"/>s.
+ Scales this instances view by the given amount.
</summary>
- <param name="vector">The original <see cref="T:StarSimLib.Vector4d"/>.</param>
- <param name="vector2">The other <see cref="T:StarSimLib.Vector4d"/>.</param>
- <returns>The new <see cref="T:StarSimLib.Vector4d"/>.</returns>
+ <param name="scaleMultiplier">The multiplier by which to scale the viewport of this instances render target.</param>
</member>
- <member name="M:StarSimLib.Vector4d.op_Addition(StarSimLib.Vector4d,System.ValueTuple{System.Double,System.Double,System.Double,System.Double})">
+ <member name="T:StarSimLib.Physics.Body">
<summary>
- Implements the addition operator for a <see cref="T:StarSimLib.Vector4d"/> and a (X, Y, Z, W) tuple.
+ Represents a stellar body.
</summary>
- <param name="vector">The original <see cref="T:StarSimLib.Vector4d"/>.</param>
- <param name="vector2">The 4D tuple.</param>
- <returns>The new <see cref="T:StarSimLib.Vector4d"/>.</returns>
</member>
- <member name="M:StarSimLib.Vector4d.op_Addition(System.ValueTuple{System.Double,System.Double,System.Double,System.Double},StarSimLib.Vector4d)">
+ <member name="F:StarSimLib.Physics.Body.BodyFormatString">
<summary>
- Implements the addition operator for a <see cref="T:StarSimLib.Vector4d"/> and a (X, Y, Z, W) tuple.
+ Describes how the <see cref="T:StarSimLib.Physics.Body"/> instance should be formatted as a <see cref="T:System.String"/>.
</summary>
- <param name="vector">The original <see cref="T:StarSimLib.Vector4d"/>.</param>
- <param name="vector2">The 4D tuple.</param>
- <returns>The new <see cref="T:StarSimLib.Vector4d"/>.</returns>
</member>
- <member name="M:StarSimLib.Vector4d.op_Addition(StarSimLib.Vector4d,System.Double)">
+ <member name="F:StarSimLib.Physics.Body.force">
<summary>
- Implements the addition operator for a <see cref="T:StarSimLib.Vector4d"/> and a scalar <see cref="T:System.Double"/> value.
+ The backing field for the <see cref="P:StarSimLib.Physics.Body.Force"/> property.
</summary>
- <param name="vector">The original <see cref="T:StarSimLib.Vector4d"/>.</param>
- <param name="scalar">The scalar <see cref="T:System.Double"/>.</param>
- <returns>The new <see cref="T:StarSimLib.Vector4d"/>.</returns>
</member>
- <member name="M:StarSimLib.Vector4d.op_Addition(System.Double,StarSimLib.Vector4d)">
+ <member name="F:StarSimLib.Physics.Body.mass">
<summary>
- Implements the addition operator for a <see cref="T:StarSimLib.Vector4d"/> and a scalar <see cref="T:System.Double"/> value.
+ Backing field for the <see cref="P:StarSimLib.Physics.Body.Mass"/> property.
</summary>
- <param name="vector">The original <see cref="T:StarSimLib.Vector4d"/>.</param>
- <param name="scalar">The scalar <see cref="T:System.Double"/>.</param>
- <returns>The new <see cref="T:StarSimLib.Vector4d"/>.</returns>
</member>
- <member name="P:StarSimLib.Vector4d.Item(System.Int32)">
+ <member name="F:StarSimLib.Physics.Body.position">
<summary>
- Indexes the vector as a 1D array.
+ Backing field for the <see cref="P:StarSimLib.Physics.Body.Position"/> property.
</summary>
- <param name="i">The column index.</param>
- <returns>The value at the specified field.</returns>
</member>
- <member name="M:StarSimLib.Vector4d.Abs">
+ <member name="F:StarSimLib.Physics.Body.velocity">
<summary>
- Returns the absolute value of this <see cref="T:StarSimLib.Vector4d"/>.
+ Backing field for the <see cref="P:StarSimLib.Physics.Body.Velocity"/> property.
</summary>
- <returns>The absolute value (magnitude) of this <see cref="T:StarSimLib.Vector4d"/>, as a <see cref="T:System.Double"/>.</returns>
</member>
- <member name="M:StarSimLib.Vector4d.Magnitude">
+ <member name="F:StarSimLib.Physics.Body.Generation">
<summary>
- Returns the magnitude of this <see cref="T:StarSimLib.Vector4d"/>.
+ The generation that this body belongs to.
</summary>
- <returns>The magnitude (absolute value) of this <see cref="T:StarSimLib.Vector4d"/>, as a <see cref="T:System.Double"/>.</returns>
</member>
- <member name="T:StarSimLib.Vector4d.UnitVectors">
+ <member name="F:StarSimLib.Physics.Body.Id">
<summary>
- Holds unit vectors.
+ The unique id for this body.
</summary>
</member>
- <member name="F:StarSimLib.Vector4d.UnitVectors.Backwards">
+ <member name="M:StarSimLib.Physics.Body.#ctor(StarSimLib.Data_Structures.Vector4d,StarSimLib.Data_Structures.Vector4d,System.Double,System.UInt32,System.UInt32)">
<summary>
- The negative unit vector for the Z axis.
+ Initialises a new instance of the <see cref="T:StarSimLib.Physics.Body"/> class.
</summary>
+ <param name="position">The starting position of the <see cref="T:StarSimLib.Physics.Body"/>.</param>
+ <param name="velocity">The starting velocity of the <see cref="T:StarSimLib.Physics.Body"/>.</param>
+ <param name="mass">The starting mass of the <see cref="T:StarSimLib.Physics.Body"/>.</param>
+ <param name="generation">The generation that this <see cref="T:StarSimLib.Physics.Body"/> belongs to.</param>
+ <param name="id">The unique id for this body.</param>
</member>
- <member name="F:StarSimLib.Vector4d.UnitVectors.Down">
+ <member name="P:StarSimLib.Physics.Body.Force">
<summary>
- The negative unit vector for the Y axis.
+ The current force on the <see cref="T:StarSimLib.Physics.Body"/> in 3D space.
</summary>
</member>
- <member name="F:StarSimLib.Vector4d.UnitVectors.Forwards">
+ <member name="P:StarSimLib.Physics.Body.Mass">
<summary>
- The positive unit vector for the Z axis.
+ The mass of the <see cref="T:StarSimLib.Physics.Body"/>.
</summary>
</member>
- <member name="F:StarSimLib.Vector4d.UnitVectors.Left">
+ <member name="P:StarSimLib.Physics.Body.Position">
<summary>
- The positive unit vector for the X axis.
+ The current position of the <see cref="T:StarSimLib.Physics.Body"/> in 3D space.
</summary>
</member>
- <member name="F:StarSimLib.Vector4d.UnitVectors.Right">
+ <member name="P:StarSimLib.Physics.Body.Velocity">
<summary>
- The negative unit vector for the X axis.
+ The current velocity of the <see cref="T:StarSimLib.Physics.Body"/> in 3D space.
</summary>
</member>
- <member name="F:StarSimLib.Vector4d.UnitVectors.Up">
+ <member name="M:StarSimLib.Physics.Body.GetForceBetween(StarSimLib.Physics.Body,StarSimLib.Physics.Body)">
<summary>
- The positive unit vector for the Y axis.
+ Gets the force vector for the attraction between <see cref="T:StarSimLib.Physics.Body"/> A and <see cref="T:StarSimLib.Physics.Body"/> B.
+ </summary>
+ <param name="a">The first <see cref="T:StarSimLib.Physics.Body"/> instance.</param>
+ <param name="b">The second <see cref="T:StarSimLib.Physics.Body"/> instance.</param>
+ <returns></returns>
+ </member>
+ <member name="M:StarSimLib.Physics.Body.AddForce(StarSimLib.Physics.Body)">
+ <summary>
+ Calculates the force between this instance and the given other body, and adds the resultant vector to the
+ internal total force vector.
+ </summary>
+ <param name="otherBody">The other body to calculate the force between.</param>
+ </member>
+ <member name="M:StarSimLib.Physics.Body.Collide(StarSimLib.Physics.Body)">
+ <summary>
+ Collides this instance with the given <see cref="T:StarSimLib.Physics.Body"/> instance.
+ </summary>
+ <param name="otherBody">The other instance with which to collide.</param>
+ </member>
+ <member name="M:StarSimLib.Physics.Body.DistanceTo(StarSimLib.Physics.Body,StarSimLib.Data_Structures.Vector4d@)">
+ <summary>
+ Finds and returns the distance between the current <see cref="T:StarSimLib.Physics.Body"/> instance and the given <see cref="T:StarSimLib.Physics.Body"/>.
+ In other words, it finds the magnitude of the translation vector between the two <see cref="T:StarSimLib.Physics.Body"/> instances.
+ </summary>
+ <param name="body">The other <see cref="T:StarSimLib.Physics.Body"/> instance to which to calculate the distance.</param>
+ <param name="displacement">The vector showing the displacement of the current body from the given one.</param>
+ <returns>The distance to the other <see cref="T:StarSimLib.Physics.Body"/> as a <see cref="T:System.Single"/>.</returns>
+ </member>
+ <member name="M:StarSimLib.Physics.Body.ResetForce">
+ <summary>
+ Resets the internal force vector.
+ </summary>
+ </member>
+ <member name="M:StarSimLib.Physics.Body.Update(System.Double)">
+ <summary>
+ Updates the <see cref="P:StarSimLib.Physics.Body.Position"/> of the current body using the internal force vector and the given time step.
</summary>
+ <param name="deltaTime">The time step.</param>
</member>
- <member name="M:StarSimLib.Vector4d.ToString">
+ <member name="M:StarSimLib.Physics.Body.Update(StarSimLib.Data_Structures.Vector4d,System.Double)">
+ <summary>
+ Updates the <see cref="P:StarSimLib.Physics.Body.Position"/> of the current body using the given force vector and time step.
+ </summary>
+ <param name="forceVector">The sum vector of all forces due to other <see cref="T:StarSimLib.Physics.Body"/>s.</param>
+ <param name="deltaTime">The time step.</param>
+ </member>
+ <member name="M:StarSimLib.Physics.Body.ToString">
<inheritdoc />
</member>
+ <member name="T:StarSimLib.Physics.BodyGenerator">
+ <summary>
+ Provides methods for generating <see cref="T:StarSimLib.Physics.Body"/> instances.
+ </summary>
+ </member>
+ <member name="F:StarSimLib.Physics.BodyGenerator.Rng">
+ <summary>
+ Caches a random number generator to use for all randomised positions and velocities.
+ </summary>
+ </member>
+ <member name="P:StarSimLib.Physics.BodyGenerator.CurrentGeneration">
+ <summary>
+ The current generation of <see cref="T:StarSimLib.Physics.Body"/> instances that the generator is on.
+ </summary>
+ </member>
+ <member name="M:StarSimLib.Physics.BodyGenerator.GenerateBodies(System.Int32,System.Boolean)">
+ <summary>
+ Generates an array of <see cref="T:StarSimLib.Physics.Body"/> instances, possibly including a central attractor.
+ </summary>
+ <param name="bodyCount">The number of <see cref="T:StarSimLib.Physics.Body"/> instances to generate.</param>
+ <param name="centralAttractor">Whether to have a central massive attractor.</param>
+ <returns>The generated <see cref="T:StarSimLib.Physics.Body"/> array.</returns>
+ </member>
+ <member name="M:StarSimLib.Physics.BodyGenerator.GenerateShapes(System.Collections.Generic.IEnumerable{StarSimLib.Physics.Body})">
+ <summary>
+ Generates a <see cref="T:System.Collections.Generic.Dictionary`2"/> mapping each given <see cref="T:StarSimLib.Physics.Body"/> to a
+ <see cref="T:SFML.Graphics.CircleShape"/> that represents the body instance in 2D space.
+ </summary>
+ <param name="bodies">The <see cref="T:StarSimLib.Physics.Body"/> instances for which to generate the shapes.</param>
+ <returns>
+ A <see cref="T:System.Collections.Generic.Dictionary`2"/> mapping the given <see cref="T:StarSimLib.Physics.Body"/> instances to their <see cref="T:SFML.Graphics.CircleShape"/> instances.
+ </returns>
+ </member>
+ <member name="T:StarSimLib.Physics.UpdateDelegate">
+ <summary>
+ Updates the given <see cref="T:StarSimLib.Physics.Body"/> collections individual bodies, using the given delta time.
+ </summary>
+ <param name="bodies">The body collection.</param>
+ <param name="deltaTime">The time step.</param>
+ </member>
+ <member name="T:StarSimLib.Physics.BodyUpdater">
+ <summary>
+ Provides methods for updating <see cref="T:StarSimLib.Physics.Body"/> instance positions.
+ </summary>
+ </member>
+ <member name="M:StarSimLib.Physics.BodyUpdater.UpdateBodiesBruteForce(System.Collections.Generic.IEnumerable{StarSimLib.Physics.Body},System.Double)">
+ <summary>
+ Updates the positions of all the given <see cref="T:StarSimLib.Physics.Body"/>s with O(n^2) time complexity, with the given time step.
+ </summary>
+ <param name="bodies">The collection of <see cref="T:StarSimLib.Physics.Body"/>s whose positions to update.</param>
+ <param name="deltaTime">The time step.</param>
+ </member>
+ <member name="T:StarSimLib.Physics.OrbitGenerator">
+ <summary>
+ Provides methods for initialising positions, velocities, and orbits for <see cref="T:StarSimLib.Physics.Body"/> instances.
+ </summary>
+ </member>
+ <member name="F:StarSimLib.Physics.OrbitGenerator.Rng">
+ <summary>
+ Random number generator.
+ </summary>
+ </member>
+ <member name="M:StarSimLib.Physics.OrbitGenerator.RandomOrbit(StarSimLib.Data_Structures.Vector4d)">
+ <summary>
+ Returns a randomised orbit around a central, heavy mass.
+ </summary>
+ <param name="positionVector">The position vector for the body for which to generate the orbit.</param>
+ <returns>The magnitude of the velocity of the orbit.</returns>
+ </member>
+ <member name="M:StarSimLib.Physics.OrbitGenerator.RandomPosition">
+ <summary>
+ Returns a random position within the universe sphere (see <see cref="F:StarSimLib.Constants.UniverseSize"/>).
+ </summary>
+ <returns>A 3D position vector.</returns>
+ </member>
</members>
</doc>
diff --git a/StarSim/StarSimLib/Vector4d.cs b/StarSim/StarSimLib/Vector4d.cs
@@ -1,461 +0,0 @@
-using System;
-using System.Diagnostics.Contracts;
-
-namespace StarSimLib
-{
- /// <summary>
- /// A 4D vector with <see cref="double"/> components.
- /// </summary>
- public struct Vector4d
- {
- /// <summary>
- /// The w component of the vector.
- /// </summary>
- public double W;
-
- /// <summary>
- /// The x component of the vector.
- /// </summary>
- public double X;
-
- /// <summary>
- /// The y component of the vector.
- /// </summary>
- public double Y;
-
- /// <summary>
- /// The z component of the vector.
- /// </summary>
- public double Z;
-
- /// <summary>
- /// Initialises a new instance of the <see cref="Vector4d"/> struct. Sets Z and W to 0.
- /// </summary>
- /// <param name="x">The x component.</param>
- /// <param name="y">The y component.</param>
- public Vector4d(double x, double y)
- {
- X = x;
- Y = y;
- Z = 0;
- W = 0;
- }
-
- /// <summary>
- /// Initialises a new instance of the <see cref="Vector4d"/> struct. Sets W to 0.
- /// </summary>
- /// <param name="x">The x component.</param>
- /// <param name="y">The y component.</param>
- /// <param name="z">The z component.</param>
- public Vector4d(double x, double y, double z)
- {
- X = x;
- Y = y;
- Z = z;
- W = 0;
- }
-
- /// <summary>
- /// Initialises a new instance of the <see cref="Vector4d"/> struct.
- /// </summary>
- /// <param name="x">The x component.</param>
- /// <param name="y">The y component.</param>
- /// <param name="z">The z component.</param>
- /// <param name="w">The w component.</param>
- public Vector4d(double x, double y, double z, double w)
- {
- X = x;
- Y = y;
- Z = z;
- W = w;
- }
-
- #region Operator Overloads
-
- /// <summary>
- /// Implements the subtraction operator for 2 <see cref="Vector4d"/>s.
- /// </summary>
- /// <param name="vector">The original <see cref="Vector4d"/>.</param>
- /// <param name="vector2">The other <see cref="Vector4d"/>.</param>
- /// <returns>The new <see cref="Vector4d"/>.</returns>
- public static Vector4d operator -(Vector4d vector, Vector4d vector2)
- {
- vector.X -= vector2.X;
- vector.Y -= vector2.Y;
- vector.Z -= vector2.Z;
- vector.W -= vector2.W;
-
- return vector;
- }
-
- /// <summary>
- /// Implements the subtraction operator for a <see cref="Vector4d"/> and a (X, Y, Z, W) tuple.
- /// </summary>
- /// <param name="vector">The original <see cref="Vector4d"/>.</param>
- /// <param name="vector2">The 4D tuple.</param>
- /// <returns>The new <see cref="Vector4d"/>.</returns>
- public static Vector4d operator -(Vector4d vector, (double X, double Y, double Z, double W) vector2)
- {
- (double x, double y, double z, double w) = vector2;
-
- vector.X -= x;
- vector.Y -= y;
- vector.Z -= z;
- vector.W -= w;
-
- return vector;
- }
-
- /// <summary>
- /// Implements the subtraction operator for a <see cref="Vector4d"/> and a (X, Y, Z, W) tuple.
- /// </summary>
- /// <param name="vector">The original <see cref="Vector4d"/>.</param>
- /// <param name="vector2">The 4D tuple.</param>
- /// <returns>The new <see cref="Vector4d"/>.</returns>
- public static Vector4d operator -((double X, double Y, double Z, double W) vector2, Vector4d vector) => vector - vector2;
-
- /// <summary>
- /// Implements the subtraction operator for a <see cref="Vector4d"/> and a scalar <see cref="double"/> value.
- /// </summary>
- /// <param name="vector">The original <see cref="Vector4d"/>.</param>
- /// <param name="scalar">The scalar <see cref="double"/>.</param>
- /// <returns>The new <see cref="Vector4d"/>.</returns>
- public static Vector4d operator -(Vector4d vector, double scalar)
- {
- vector.X -= scalar;
- vector.Y -= scalar;
- vector.Z -= scalar;
- vector.W -= scalar;
-
- return vector;
- }
-
- /// <summary>
- /// Implements the subtraction operator for a <see cref="Vector4d"/> and a scalar <see cref="double"/> value.
- /// </summary>
- /// <param name="vector">The original <see cref="Vector4d"/>.</param>
- /// <param name="scalar">The scalar <see cref="double"/>.</param>
- /// <returns>The new <see cref="Vector4d"/>.</returns>
- public static Vector4d operator -(double scalar, Vector4d vector) => vector - scalar;
-
- /// <summary>
- /// Implements the multiplication operator for 2 <see cref="Vector4d"/>s.
- /// </summary>
- /// <param name="vector">The original <see cref="Vector4d"/>.</param>
- /// <param name="vector2">The other <see cref="Vector4d"/>.</param>
- /// <returns>The new <see cref="Vector4d"/>.</returns>
- public static Vector4d operator *(Vector4d vector, Vector4d vector2)
- {
- vector.X *= vector2.X;
- vector.Y *= vector2.Y;
- vector.Z *= vector2.Z;
- vector.W *= vector2.W;
-
- return vector;
- }
-
- /// <summary>
- /// Implements the multiplication operator for a <see cref="Vector4d"/> and a (X, Y, Z, W) tuple.
- /// </summary>
- /// <param name="vector">The original <see cref="Vector4d"/>.</param>
- /// <param name="vector2">The 4D tuple.</param>
- /// <returns>The new <see cref="Vector4d"/>.</returns>
- public static Vector4d operator *(Vector4d vector, (double X, double Y, double Z, double W) vector2)
- {
- (double x, double y, double z, double w) = vector2;
-
- vector.X *= x;
- vector.Y *= y;
- vector.Z *= z;
- vector.W *= w;
-
- return vector;
- }
-
- /// <summary>
- /// Implements the multiplication operator for a <see cref="Vector4d"/> and a (X, Y, Z, W) tuple.
- /// </summary>
- /// <param name="vector">The original <see cref="Vector4d"/>.</param>
- /// <param name="vector2">The 4D tuple.</param>
- /// <returns>The new <see cref="Vector4d"/>.</returns>
- public static Vector4d operator *((double X, double Y, double Z, double W) vector2, Vector4d vector) => vector * vector2;
-
- /// <summary>
- /// Implements the multiplication operator for a <see cref="Vector4d"/> and a scalar <see cref="double"/> value.
- /// </summary>
- /// <param name="vector">The original <see cref="Vector4d"/>.</param>
- /// <param name="scalar">The scalar <see cref="double"/>.</param>
- /// <returns>The new <see cref="Vector4d"/>.</returns>
- public static Vector4d operator *(Vector4d vector, double scalar)
- {
- vector.X *= scalar;
- vector.Y *= scalar;
- vector.Z *= scalar;
- vector.W *= scalar;
-
- return vector;
- }
-
- /// <summary>
- /// Implements the multiplication operator for a <see cref="Vector4d"/> and a scalar <see cref="double"/> value.
- /// </summary>
- /// <param name="vector">The original <see cref="Vector4d"/>.</param>
- /// <param name="scalar">The scalar <see cref="double"/>.</param>
- /// <returns>The new <see cref="Vector4d"/>.</returns>
- public static Vector4d operator *(double scalar, Vector4d vector) => vector * scalar;
-
- /// <summary>
- /// Implements the division operator for 2 <see cref="Vector4d"/>s.
- /// </summary>
- /// <param name="vector">The original <see cref="Vector4d"/>.</param>
- /// <param name="vector2">The other <see cref="Vector4d"/>.</param>
- /// <returns>The new <see cref="Vector4d"/>.</returns>
- public static Vector4d operator /(Vector4d vector, Vector4d vector2)
- {
- vector.X /= vector2.X;
- vector.Y /= vector2.Y;
- vector.Z /= vector2.Z;
- vector.W /= vector2.W;
-
- return vector;
- }
-
- /// <summary>
- /// Implements the division operator for a <see cref="Vector4d"/> and a (X, Y, Z, W) tuple.
- /// </summary>
- /// <param name="vector">The original <see cref="Vector4d"/>.</param>
- /// <param name="vector2">The 4D tuple.</param>
- /// <returns>The new <see cref="Vector4d"/>.</returns>
- public static Vector4d operator /(Vector4d vector, (double X, double Y, double Z, double W) vector2)
- {
- (double x, double y, double z, double w) = vector2;
-
- vector.X /= x;
- vector.Y /= y;
- vector.Z /= z;
- vector.W /= w;
-
- return vector;
- }
-
- /// <summary>
- /// Implements the division operator for a <see cref="Vector4d"/> and a (X, Y, Z, W) tuple.
- /// </summary>
- /// <param name="vector">The original <see cref="Vector4d"/>.</param>
- /// <param name="vector2">The 4D tuple.</param>
- /// <returns>The new <see cref="Vector4d"/>.</returns>
- public static Vector4d operator /((double X, double Y, double Z, double W) vector2, Vector4d vector) => vector / vector2;
-
- /// <summary>
- /// Implements the division operator for a <see cref="Vector4d"/> and a scalar <see cref="double"/> value.
- /// </summary>
- /// <param name="vector">The original <see cref="Vector4d"/>.</param>
- /// <param name="scalar">The scalar <see cref="double"/>.</param>
- /// <returns>The new <see cref="Vector4d"/>.</returns>
- public static Vector4d operator /(Vector4d vector, double scalar)
- {
- vector.X /= scalar;
- vector.Y /= scalar;
- vector.Z /= scalar;
- vector.W /= scalar;
-
- return vector;
- }
-
- /// <summary>
- /// Implements the division operator for a <see cref="Vector4d"/> and a scalar <see cref="double"/> value.
- /// </summary>
- /// <param name="vector">The original <see cref="Vector4d"/>.</param>
- /// <param name="scalar">The scalar <see cref="double"/>.</param>
- /// <returns>The new <see cref="Vector4d"/>.</returns>
- public static Vector4d operator /(double scalar, Vector4d vector) => vector / scalar;
-
- /// <summary>
- /// Implements the addition operator for 2 <see cref="Vector4d"/>s.
- /// </summary>
- /// <param name="vector">The original <see cref="Vector4d"/>.</param>
- /// <param name="vector2">The other <see cref="Vector4d"/>.</param>
- /// <returns>The new <see cref="Vector4d"/>.</returns>
- public static Vector4d operator +(Vector4d vector, Vector4d vector2)
- {
- vector.X += vector2.X;
- vector.Y += vector2.Y;
- vector.Z += vector2.Z;
- vector.W += vector2.W;
-
- return vector;
- }
-
- /// <summary>
- /// Implements the addition operator for a <see cref="Vector4d"/> and a (X, Y, Z, W) tuple.
- /// </summary>
- /// <param name="vector">The original <see cref="Vector4d"/>.</param>
- /// <param name="vector2">The 4D tuple.</param>
- /// <returns>The new <see cref="Vector4d"/>.</returns>
- public static Vector4d operator +(Vector4d vector, (double X, double Y, double Z, double W) vector2)
- {
- (double x, double y, double z, double w) = vector2;
-
- vector.X += x;
- vector.Y += y;
- vector.Z += z;
- vector.W += w;
-
- return vector;
- }
-
- /// <summary>
- /// Implements the addition operator for a <see cref="Vector4d"/> and a (X, Y, Z, W) tuple.
- /// </summary>
- /// <param name="vector">The original <see cref="Vector4d"/>.</param>
- /// <param name="vector2">The 4D tuple.</param>
- /// <returns>The new <see cref="Vector4d"/>.</returns>
- public static Vector4d operator +((double X, double Y, double Z, double W) vector2, Vector4d vector) => vector + vector2;
-
- /// <summary>
- /// Implements the addition operator for a <see cref="Vector4d"/> and a scalar <see cref="double"/> value.
- /// </summary>
- /// <param name="vector">The original <see cref="Vector4d"/>.</param>
- /// <param name="scalar">The scalar <see cref="double"/>.</param>
- /// <returns>The new <see cref="Vector4d"/>.</returns>
- public static Vector4d operator +(Vector4d vector, double scalar)
- {
- vector.X += scalar;
- vector.Y += scalar;
- vector.Z += scalar;
- vector.W += scalar;
-
- return vector;
- }
-
- /// <summary>
- /// Implements the addition operator for a <see cref="Vector4d"/> and a scalar <see cref="double"/> value.
- /// </summary>
- /// <param name="vector">The original <see cref="Vector4d"/>.</param>
- /// <param name="scalar">The scalar <see cref="double"/>.</param>
- /// <returns>The new <see cref="Vector4d"/>.</returns>
- public static Vector4d operator +(double scalar, Vector4d vector) => vector + scalar;
-
- #endregion Operator Overloads
-
- /// <summary>
- /// Indexes the vector as a 1D array.
- /// </summary>
- /// <param name="i">The column index.</param>
- /// <returns>The value at the specified field.</returns>
- public double this[int i]
- {
- get
- {
- switch (i)
- {
- case 0:
- return X;
-
- case 1:
- return Y;
-
- case 2:
- return Z;
-
- case 3:
- return W;
-
- default:
- return 0;
- }
- }
-
- set
- {
- switch (i)
- {
- case 0:
- X = value;
- break;
-
- case 1:
- Y = value;
- break;
-
- case 2:
- Z = value;
- break;
-
- case 3:
- W = value;
- break;
-
- default:
- break;
- }
- }
- }
-
- /// <summary>
- /// Returns the absolute value of this <see cref="Vector4d"/>.
- /// </summary>
- /// <returns>The absolute value (magnitude) of this <see cref="Vector4d"/>, as a <see cref="double"/>.</returns>
- [Pure]
- public double Abs()
- {
- return Math.Sqrt(X * X + Y * Y + Z * Z + W * W);
- }
-
- /// <summary>
- /// Returns the magnitude of this <see cref="Vector4d"/>.
- /// </summary>
- /// <returns>The magnitude (absolute value) of this <see cref="Vector4d"/>, as a <see cref="double"/>.</returns>
- [Pure]
- public double Magnitude()
- {
- return Abs();
- }
-
- /// <summary>
- /// Holds unit vectors.
- /// </summary>
- public static class UnitVectors
- {
- /// <summary>
- /// The negative unit vector for the Z axis.
- /// </summary>
- public static readonly Vector4d Backwards = new Vector4d(0, 0, -1);
-
- /// <summary>
- /// The negative unit vector for the Y axis.
- /// </summary>
- public static readonly Vector4d Down = new Vector4d(0, -1, 0);
-
- /// <summary>
- /// The positive unit vector for the Z axis.
- /// </summary>
- public static readonly Vector4d Forwards = new Vector4d(0, 0, 1);
-
- /// <summary>
- /// The positive unit vector for the X axis.
- /// </summary>
- public static readonly Vector4d Left = new Vector4d(1, 0, 0);
-
- /// <summary>
- /// The negative unit vector for the X axis.
- /// </summary>
- public static readonly Vector4d Right = new Vector4d(-1, 0, 0);
-
- /// <summary>
- /// The positive unit vector for the Y axis.
- /// </summary>
- public static readonly Vector4d Up = new Vector4d(0, 1, 0);
- }
-
- #region Overrides of ValueType
-
- /// <inheritdoc />
- public override string ToString()
- {
- return $"[{X}, {Y}, {Z}, {W}]";
- }
-
- #endregion Overrides of ValueType
- }
-}
-\ No newline at end of file