Added (Vector3, float) and (Vector3d, double) constructors.

This commit is contained in:
the_fiddler 2009-01-29 00:41:09 +00:00
parent 561b90a0eb
commit 989b0c81c6
2 changed files with 40 additions and 6 deletions

View file

@ -130,6 +130,19 @@ namespace OpenTK.Math
W = 0.0f;
}
/// <summary>
/// Constructs a new Vector4 from the specified Vector3 and W component.
/// </summary>
/// <param name="v">The Vector3 to copy components from.</param>
/// <param name="w">The W component of the new Vector4.</param>
public Vector4(Vector3 v, float w)
{
X = v.X;
Y = v.Y;
Z = v.Z;
W = w;
}
/// <summary>
/// Constructs a new Vector4 from the given Vector4.
/// </summary>
@ -812,6 +825,14 @@ namespace OpenTK.Math
#endregion
#region Swizzle
public Vector2 Xy { get { return new Vector2(X, Y); } set { X = value.X; Y = value.Y; } }
public Vector3 Xyz { get { return new Vector3(X, Y, Z); } set { X = value.X; Y = value.Y; Z = value.Z; } }
#endregion
#region Operators
public static Vector4 operator +(Vector4 left, Vector4 right)

View file

@ -104,10 +104,10 @@ namespace OpenTK.Math
}
/// <summary>
/// Constructs a new Vector4d from the given Vector2.
/// Constructs a new Vector4d from the given Vector2d.
/// </summary>
/// <param name="v">The Vector2 to copy components from.</param>
public Vector4d(Vector2 v)
/// <param name="v">The Vector2d to copy components from.</param>
public Vector4d(Vector2d v)
{
X = v.X;
Y = v.Y;
@ -116,10 +116,10 @@ namespace OpenTK.Math
}
/// <summary>
/// Constructs a new Vector4d from the given Vector3.
/// Constructs a new Vector4d from the given Vector3d.
/// </summary>
/// <param name="v">The Vector3 to copy components from.</param>
public Vector4d(Vector3 v)
/// <param name="v">The Vector3d to copy components from.</param>
public Vector4d(Vector3d v)
{
X = v.X;
Y = v.Y;
@ -127,6 +127,19 @@ namespace OpenTK.Math
W = 0.0f;
}
/// <summary>
/// Constructs a new Vector4d from the specified Vector3d and W component.
/// </summary>
/// <param name="v">The Vector3d to copy components from.</param>
/// <param name="w">The W component of the new Vector4.</param>
public Vector4d(Vector3 v, double w)
{
X = v.X;
Y = v.Y;
Z = v.Z;
W = w;
}
/// <summary>
/// Constructs a new Vector4d from the given Vector4d.
/// </summary>