Added instance methods to all single and double precision Vector structs:

Add(ref vec)
Sub(ref vec)
Mult(float)
Div(float)
Scale(ref vec)
This commit is contained in:
chrisbrandtner 2009-01-23 21:55:21 +00:00
parent fabc194301
commit 4e6a3cf981
6 changed files with 264 additions and 11 deletions

View file

@ -101,6 +101,55 @@ namespace OpenTK.Math
#region Instance
#region public void Add()
/// <summary>Add the Vector passed as parameter to this instance.</summary>
/// <param name="right">Right operand. This parameter is only read from.</param>
public void Add( ref Vector2 right )
{
this.X += right.X;
this.Y += right.Y;
}
#endregion public void Add()
#region public void Sub()
/// <summary>Subtract the Vector passed as parameter from this instance.</summary>
/// <param name="right">Right operand. This parameter is only read from.</param>
public void Sub( ref Vector2 right )
{
this.X -= right.X;
this.Y -= right.Y;
}
#endregion public void Sub()
#region public void Mult()
/// <summary>Multiply this instance by a scalar.</summary>
/// <param name="f">Scalar operand.</param>
public void Mult( float f )
{
this.X *= f;
this.Y *= f;
}
#endregion public void Mult()
#region public void Div()
/// <summary>Divide this instance by a scalar.</summary>
/// <param name="f">Scalar operand.</param>
public void Div( float f )
{
float mult = 1.0f / f;
this.X *= mult;
this.Y *= mult;
}
#endregion public void Div()
#region public float Length
/// <summary>
@ -219,7 +268,7 @@ namespace OpenTK.Math
#endregion
#region public void Scale(float sx, float sy)
#region public void Scale()
/// <summary>
/// Scales the current Vector2 by the given amounts.
@ -232,7 +281,15 @@ namespace OpenTK.Math
this.Y = Y * sy;
}
#endregion
/// <summary>Scales this instance by the given parameter.</summary>
/// <param name="scale">The scaling of the individual components.</param>
public void Scale( ref Vector2 scale )
{
this.X *= scale.X;
this.Y *= scale.Y;
}
#endregion public void Scale()
#endregion

Binary file not shown.

View file

@ -107,6 +107,59 @@ namespace OpenTK.Math
#region Public Members
#region Instance
#region public void Add()
/// <summary>Add the Vector passed as parameter to this instance.</summary>
/// <param name="right">Right operand. This parameter is only read from.</param>
public void Add( ref Vector3 right )
{
this.X += right.X;
this.Y += right.Y;
this.Z += right.Z;
}
#endregion public void Add()
#region public void Sub()
/// <summary>Subtract the Vector passed as parameter from this instance.</summary>
/// <param name="right">Right operand. This parameter is only read from.</param>
public void Sub( ref Vector3 right )
{
this.X -= right.X;
this.Y -= right.Y;
this.Z -= right.Z;
}
#endregion public void Sub()
#region public void Mult()
/// <summary>Multiply this instance by a scalar.</summary>
/// <param name="f">Scalar operand.</param>
public void Mult( float f )
{
this.X *= f;
this.Y *= f;
this.Z *= f;
}
#endregion public void Mult()
#region public void Div()
/// <summary>Divide this instance by a scalar.</summary>
/// <param name="f">Scalar operand.</param>
public void Div( float f )
{
float mult = 1.0f / f;
this.X *= mult;
this.Y *= mult;
this.Z *= mult;
}
#endregion public void Div()
#region public float Length
@ -198,7 +251,7 @@ namespace OpenTK.Math
#endregion
#region public void Scale(float sx, float sy, float sz)
#region public void Scale()
/// <summary>
/// Scales the current Vector3 by the given amounts.
@ -213,7 +266,16 @@ namespace OpenTK.Math
this.Z = Z * sz;
}
#endregion
/// <summary>Scales this instance by the given parameter.</summary>
/// <param name="scale">The scaling of the individual components.</param>
public void Scale( ref Vector3 scale )
{
this.X *= scale.X;
this.Y *= scale.Y;
this.Z *= scale.Z;
}
#endregion public void Scale()
#endregion

Binary file not shown.

View file

@ -148,6 +148,63 @@ namespace OpenTK.Math
#region Instance
#region public void Add()
/// <summary>Add the Vector passed as parameter to this instance.</summary>
/// <param name="right">Right operand. This parameter is only read from.</param>
public void Add( ref Vector4 right )
{
this.X += right.X;
this.Y += right.Y;
this.Z += right.Z;
this.W += right.W;
}
#endregion public void Add()
#region public void Sub()
/// <summary>Subtract the Vector passed as parameter from this instance.</summary>
/// <param name="right">Right operand. This parameter is only read from.</param>
public void Sub( ref Vector4 right )
{
this.X -= right.X;
this.Y -= right.Y;
this.Z -= right.Z;
this.W -= right.W;
}
#endregion public void Sub()
#region public void Mult()
/// <summary>Multiply this instance by a scalar.</summary>
/// <param name="f">Scalar operand.</param>
public void Mult( float f )
{
this.X *= f;
this.Y *= f;
this.Z *= f;
this.W *= f;
}
#endregion public void Mult()
#region public void Div()
/// <summary>Divide this instance by a scalar.</summary>
/// <param name="f">Scalar operand.</param>
public void Div( float f )
{
float mult = 1.0f / f;
this.X *= mult;
this.Y *= mult;
this.Z *= mult;
this.W *= mult;
}
#endregion public void Div()
#region public float Length
/// <summary>
@ -240,7 +297,7 @@ namespace OpenTK.Math
#endregion
#region public void Scale(float sx, float sy, float sz, float sw)
#region public void Scale()
/// <summary>
/// Scales the current Vector4 by the given amounts.
@ -249,15 +306,25 @@ namespace OpenTK.Math
/// <param name="sy">The scale of the Y component.</param>
/// <param name="sz">The scale of the Z component.</param>
/// <param name="sw">The scale of the Z component.</param>
public void Scale(float sx, float sy, float sz, float sw)
public void Scale( float sx, float sy, float sz, float sw )
{
this.X = X * sx;
this.Y = Y * sy;
this.Z = Z * sz;
this.W = W * sw;
}
}
#endregion
/// <summary>Scales this instance by the given parameter.</summary>
/// <param name="scale">The scaling of the individual components.</param>
public void Scale( ref Vector4 scale )
{
this.X *= scale.X;
this.Y *= scale.Y;
this.Z *= scale.Z;
this.W *= scale.W;
}
#endregion public void Scale()
#endregion

View file

@ -145,6 +145,63 @@ namespace OpenTK.Math
#region Instance
#region public void Add()
/// <summary>Add the Vector passed as parameter to this instance.</summary>
/// <param name="right">Right operand. This parameter is only read from.</param>
public void Add( ref Vector4d right )
{
this.X += right.X;
this.Y += right.Y;
this.Z += right.Z;
this.W += right.W;
}
#endregion public void Add()
#region public void Sub()
/// <summary>Subtract the Vector passed as parameter from this instance.</summary>
/// <param name="right">Right operand. This parameter is only read from.</param>
public void Sub( ref Vector4d right )
{
this.X -= right.X;
this.Y -= right.Y;
this.Z -= right.Z;
this.W -= right.W;
}
#endregion public void Sub()
#region public void Mult()
/// <summary>Multiply this instance by a scalar.</summary>
/// <param name="f">Scalar operand.</param>
public void Mult( double f )
{
this.X *= f;
this.Y *= f;
this.Z *= f;
this.W *= f;
}
#endregion public void Mult()
#region public void Div()
/// <summary>Divide this instance by a scalar.</summary>
/// <param name="f">Scalar operand.</param>
public void Div( double f )
{
double mult = 1.0 / f;
this.X *= mult;
this.Y *= mult;
this.Z *= mult;
this.W *= mult;
}
#endregion public void Div()
#region public double Length
/// <summary>
@ -237,7 +294,7 @@ namespace OpenTK.Math
#endregion
#region public void Scale(double sx, double sy, double sz, double sw)
#region public void Scale()
/// <summary>
/// Scales the current Vector4d by the given amounts.
@ -252,9 +309,19 @@ namespace OpenTK.Math
this.Y = Y * sy;
this.Z = Z * sz;
this.W = W * sw;
}
}
#endregion
/// <summary>Scales this instance by the given parameter.</summary>
/// <param name="scale">The scaling of the individual components.</param>
public void Scale( ref Vector4d scale )
{
this.X *= scale.X;
this.Y *= scale.Y;
this.Z *= scale.Z;
this.W *= scale.W;
}
#endregion public void Scale()
#endregion