Added missing summeries #1
This commit is contained in:
parent
03d99ea28e
commit
8665b5b709
104 changed files with 1165 additions and 821 deletions
|
|
@ -1,39 +1,18 @@
|
|||
using System;
|
||||
using OpenTK;
|
||||
#region usings
|
||||
|
||||
using System;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace SM.Base.Types
|
||||
{
|
||||
/// <summary>
|
||||
/// A One-dimensional Vector (also known as <see cref="float"/>), in a class.
|
||||
/// A One-dimensional Vector (also known as <see cref="float" />), in a class.
|
||||
/// </summary>
|
||||
public class CVector1
|
||||
{
|
||||
/// <summary>
|
||||
/// X - Component
|
||||
/// </summary>
|
||||
public float X
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The length/magnitute of the vector.
|
||||
/// </summary>
|
||||
public float Length => GetLength();
|
||||
/// <summary>
|
||||
/// Gets the square of the vector length (magnitude).
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This property avoids the costly square root operation required by the Length property. This makes it more suitable
|
||||
/// for comparisons.
|
||||
/// </remarks>
|
||||
public float LengthSquared => GetLength(true);
|
||||
|
||||
public event Action Changed;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a class vector
|
||||
/// Creates a class vector
|
||||
/// </summary>
|
||||
/// <param name="x">X-Component</param>
|
||||
public CVector1(float x)
|
||||
|
|
@ -41,10 +20,33 @@ namespace SM.Base.Types
|
|||
X = x;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// X - Component
|
||||
/// </summary>
|
||||
public float X { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Get the length of the vector.
|
||||
/// The length/magnitute of the vector.
|
||||
/// </summary>
|
||||
public float Length => GetLength();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the square of the vector length (magnitude).
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This property avoids the costly square root operation required by the Length property. This makes it more suitable
|
||||
/// for comparisons.
|
||||
/// </remarks>
|
||||
public float LengthSquared => GetLength(true);
|
||||
|
||||
/// <summary>
|
||||
/// This event triggers when a component changed.
|
||||
/// </summary>
|
||||
public event Action Changed;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get the length of the vector.
|
||||
/// </summary>
|
||||
/// <param name="squared">If true, it will return the squared product.</param>
|
||||
/// <returns></returns>
|
||||
|
|
@ -57,7 +59,7 @@ namespace SM.Base.Types
|
|||
|
||||
|
||||
/// <summary>
|
||||
/// Normalizes the vector.
|
||||
/// Normalizes the vector.
|
||||
/// </summary>
|
||||
public void Normalize()
|
||||
{
|
||||
|
|
@ -66,7 +68,7 @@ namespace SM.Base.Types
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the X-Component.
|
||||
/// Sets the X-Component.
|
||||
/// </summary>
|
||||
/// <param name="x">X-Component</param>
|
||||
public virtual void Set(float uniform, bool triggerChanged = true)
|
||||
|
|
@ -75,6 +77,11 @@ namespace SM.Base.Types
|
|||
if (triggerChanged) TriggerChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the value to the components.
|
||||
/// </summary>
|
||||
/// <param name="uniform"></param>
|
||||
/// <param name="triggerChanged"></param>
|
||||
public virtual void Add(float uniform, bool triggerChanged = true)
|
||||
{
|
||||
X += uniform;
|
||||
|
|
@ -82,20 +89,24 @@ namespace SM.Base.Types
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Conversion into <see cref="float"/>
|
||||
/// Conversion into <see cref="float" />
|
||||
/// </summary>
|
||||
public static implicit operator float(CVector1 vector1) => vector1.X;
|
||||
public static implicit operator float(CVector1 vector1)
|
||||
{
|
||||
return vector1.X;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Conversion from <see cref="float"/> to One-dimensional Vector.
|
||||
/// Conversion from <see cref="float" /> to One-dimensional Vector.
|
||||
/// </summary>
|
||||
/// <param name="f"></param>
|
||||
/// <returns></returns>
|
||||
//public static implicit operator CVector1(float f) => new CVector1(f);
|
||||
|
||||
protected virtual float GetLengthProcess()
|
||||
{
|
||||
return X * X;
|
||||
}
|
||||
|
||||
protected virtual void NormalizationProcess(float length)
|
||||
{
|
||||
X *= length;
|
||||
|
|
|
|||
|
|
@ -1,19 +1,18 @@
|
|||
using OpenTK;
|
||||
#region usings
|
||||
|
||||
using OpenTK;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace SM.Base.Types
|
||||
{
|
||||
/// <summary>
|
||||
/// A two-dimensional vector.
|
||||
/// A two-dimensional vector.
|
||||
/// </summary>
|
||||
public class CVector2 : CVector1
|
||||
{
|
||||
/// <summary>
|
||||
/// Y-component
|
||||
/// </summary>
|
||||
public float Y { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a vector, where each component is the same value.
|
||||
/// Creates a vector, where each component is the same value.
|
||||
/// </summary>
|
||||
/// <param name="uniform">The Value</param>
|
||||
public CVector2(float uniform) : base(uniform)
|
||||
|
|
@ -22,18 +21,25 @@ namespace SM.Base.Types
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a vector
|
||||
/// Creates a vector
|
||||
/// </summary>
|
||||
public CVector2(float x, float y) : base(x)
|
||||
{
|
||||
Y = y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Y-component
|
||||
/// </summary>
|
||||
public float Y { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override float GetLengthProcess()
|
||||
{
|
||||
return base.GetLengthProcess() + Y * Y;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void NormalizationProcess(float length)
|
||||
{
|
||||
base.NormalizationProcess(length);
|
||||
|
|
@ -41,7 +47,7 @@ namespace SM.Base.Types
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets each component to the same value
|
||||
/// Sets each component to the same value
|
||||
/// </summary>
|
||||
/// <param name="uniform"></param>
|
||||
public override void Set(float uniform, bool triggerChanged = true)
|
||||
|
|
@ -51,7 +57,7 @@ namespace SM.Base.Types
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets each component to the <see cref="Vector2"/> counter-part.
|
||||
/// Sets each component to the <see cref="Vector2" /> counter-part.
|
||||
/// </summary>
|
||||
/// <param name="vector"></param>
|
||||
public void Set(Vector2 vector, bool triggerChanged = true)
|
||||
|
|
@ -60,7 +66,7 @@ namespace SM.Base.Types
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the a own value to each component.
|
||||
/// Sets the a own value to each component.
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
|
|
@ -70,17 +76,29 @@ namespace SM.Base.Types
|
|||
base.Set(x, triggerChanged);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Add(float uniform, bool triggerChanged = true)
|
||||
{
|
||||
Y += uniform;
|
||||
base.Add(uniform, triggerChanged);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds <see cref="Vector2"/> to the CVector.
|
||||
/// </summary>
|
||||
/// <param name="vector"></param>
|
||||
/// <param name="triggerChanged">If false, the event Changed doesn't gets triggered </param>
|
||||
public void Add(Vector2 vector, bool triggerChanged = true)
|
||||
{
|
||||
Add(vector.X, vector.Y, triggerChanged);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the values to the CVector.
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
/// <param name="triggerChanged">If false, the event Changed doesn't gets triggered </param>
|
||||
public void Add(float x, float y, bool triggerChanged = true)
|
||||
{
|
||||
Y += y;
|
||||
|
|
@ -88,12 +106,19 @@ namespace SM.Base.Types
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts to <see cref="Vector2"/>
|
||||
/// Converts to <see cref="Vector2" />
|
||||
/// </summary>
|
||||
public static implicit operator Vector2(CVector2 vector2) => new Vector2(vector2.X, vector2.Y);
|
||||
public static implicit operator Vector2(CVector2 vector2)
|
||||
{
|
||||
return new Vector2(vector2.X, vector2.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts from <see cref="Vector2"/> to <see cref="CVector2"/>.
|
||||
/// Converts from <see cref="Vector2" /> to <see cref="CVector2" />.
|
||||
/// </summary>
|
||||
public static implicit operator CVector2(Vector2 vector2) => new CVector2(vector2.X, vector2.Y);
|
||||
public static implicit operator CVector2(Vector2 vector2)
|
||||
{
|
||||
return new CVector2(vector2.X, vector2.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,38 +1,45 @@
|
|||
using OpenTK;
|
||||
#region usings
|
||||
|
||||
using OpenTK;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace SM.Base.Types
|
||||
{
|
||||
/// <summary>
|
||||
/// A three-dimensional vector.
|
||||
/// A three-dimensional vector.
|
||||
/// </summary>
|
||||
public class CVector3 : CVector2
|
||||
{
|
||||
/// <summary>
|
||||
/// Z-component
|
||||
/// </summary>
|
||||
public float Z { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a vector, where each component is the same value.
|
||||
/// Creates a vector, where each component is the same value.
|
||||
/// </summary>
|
||||
/// <param name="uniform">The Value</param>
|
||||
public CVector3(float uniform) : base(uniform)
|
||||
{
|
||||
Z = uniform;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a vector
|
||||
/// Creates a vector
|
||||
/// </summary>
|
||||
public CVector3(float x, float y, float z) : base(x, y)
|
||||
{
|
||||
Z = z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Z-component
|
||||
/// </summary>
|
||||
public float Z { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override float GetLengthProcess()
|
||||
{
|
||||
return base.GetLengthProcess() + Z * Z;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void NormalizationProcess(float length)
|
||||
{
|
||||
base.NormalizationProcess(length);
|
||||
|
|
@ -47,15 +54,16 @@ namespace SM.Base.Types
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the a own value to each component.
|
||||
/// Sets the a own value to each component.
|
||||
/// </summary>
|
||||
public void Set(float x, float y, float z, bool triggerChanged = true)
|
||||
{
|
||||
Z = z;
|
||||
base.Set(x,y, triggerChanged);
|
||||
base.Set(x, y, triggerChanged);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets each component to the <see cref="Vector3"/> counter-part.
|
||||
/// Sets each component to the <see cref="Vector3" /> counter-part.
|
||||
/// </summary>
|
||||
/// <param name="vector"></param>
|
||||
public void Set(Vector3 vector, bool triggerChanged = true)
|
||||
|
|
@ -63,30 +71,50 @@ namespace SM.Base.Types
|
|||
Set(vector.X, vector.Y, vector.Z, triggerChanged);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Add(float uniform, bool triggerChanged = true)
|
||||
{
|
||||
Z += uniform;
|
||||
base.Add(uniform, triggerChanged);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a <see cref="Vector3"/> to the CVector.
|
||||
/// </summary>
|
||||
/// <param name="vector"></param>
|
||||
/// <param name="triggerChanged">If false, the event Changed doesn't gets triggered </param>
|
||||
public void Add(Vector3 vector, bool triggerChanged = true)
|
||||
{
|
||||
Add(vector.X, vector.Y, vector.Z, triggerChanged);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the values to the CVector.
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
/// <param name="z"></param>
|
||||
/// <param name="triggerChanged">If false, the event Changed doesn't gets triggered </param>
|
||||
public void Add(float x, float y, float z, bool triggerChanged = true)
|
||||
{
|
||||
Z += z;
|
||||
base.Add(x,y, triggerChanged);
|
||||
base.Add(x, y, triggerChanged);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts to <see cref="Vector3"/>
|
||||
/// Converts to <see cref="Vector3" />
|
||||
/// </summary>
|
||||
public static implicit operator Vector3(CVector3 vector) => new Vector3(vector.X, vector.Y, vector.Z);
|
||||
public static implicit operator Vector3(CVector3 vector)
|
||||
{
|
||||
return new Vector3(vector.X, vector.Y, vector.Z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts from <see cref="Vector3"/> to <see cref="CVector3"/>.
|
||||
/// Converts from <see cref="Vector3" /> to <see cref="CVector3" />.
|
||||
/// </summary>
|
||||
public static implicit operator CVector3(Vector3 vector) => new CVector3(vector.X, vector.Y, vector.Z);
|
||||
public static implicit operator CVector3(Vector3 vector)
|
||||
{
|
||||
return new CVector3(vector.X, vector.Y, vector.Z);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue