Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport docs for System.Numerics.Vectors #47725

Merged
merged 30 commits into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a82832e
Unavoidable refresh by Visual Studio of the csproj file.
carlossanlop Feb 1, 2021
770136b
Backport Matrix3x2
carlossanlop Feb 1, 2021
003afb2
Backport Matrix4x4
carlossanlop Feb 1, 2021
341cd5d
Backport Plane
carlossanlop Feb 1, 2021
c9b1b43
Backport Quaternion
carlossanlop Feb 1, 2021
f13c561
Backport Vector
carlossanlop Feb 1, 2021
8ba447a
Backport Vector2
carlossanlop Feb 1, 2021
b19650f
Backport Vector3
carlossanlop Feb 1, 2021
73d12fc
Backport Vector4
carlossanlop Feb 1, 2021
d558fec
Manually fix Plane < and >
carlossanlop Feb 1, 2021
9892f9e
Manually fix Vector wrong param names
carlossanlop Feb 1, 2021
110747b
Manually fix Vector2 < and >
carlossanlop Feb 1, 2021
eb53a7f
Manually fix Vector3 < and >
carlossanlop Feb 1, 2021
17f0fb9
Manually fix Vector4 < and >
carlossanlop Feb 1, 2021
23e4e67
Add GenerateDocumentationFile to csproj
carlossanlop Feb 1, 2021
2f63536
Revert csproj GenerateDocumentationFile change
carlossanlop Feb 1, 2021
1e112e4
Revert file fully
carlossanlop Feb 1, 2021
e74ae89
Fix typo "Multiples" => "Multiplies"
carlossanlop Feb 1, 2021
25324ac
Use <typeparamref name="T" /> instead of <c>T</c>
carlossanlop Feb 1, 2021
92bf4da
Matrix3x2 adjust remarks.
carlossanlop Feb 10, 2021
2703bb3
Quaternion address remarks.
carlossanlop Feb 10, 2021
d1af7c2
Plane adjust remarks.
carlossanlop Feb 10, 2021
98fa118
Vector4 adjust remarks.
carlossanlop Feb 10, 2021
faee5b3
Matrix4x4 adjust remarks.
carlossanlop Feb 10, 2021
fbe8c4b
Vector2 adjust remarks.
carlossanlop Feb 10, 2021
c764c06
Vector3 adjust remarks.
carlossanlop Feb 10, 2021
4095f29
Address tannergooding and gewarren suggestions.
carlossanlop Feb 10, 2021
82e533c
Matrix4x4 tries to invert.
carlossanlop Feb 10, 2021
370322c
Bring back GenerateDocumentationFile in csproj
carlossanlop Feb 10, 2021
e760180
Revert sln change
carlossanlop Feb 11, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 68 additions & 61 deletions src/libraries/System.Numerics.Vectors/System.Numerics.Vectors.sln

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
<TargetFrameworks>$(NetCoreAppCurrent)</TargetFrameworks>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
carlossanlop marked this conversation as resolved.
Show resolved Hide resolved
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="$(CoreLibProject)" />
</ItemGroup>
</Project>
</Project>
211 changes: 116 additions & 95 deletions src/libraries/System.Private.CoreLib/src/System/Numerics/Matrix3x2.cs

Large diffs are not rendered by default.

373 changes: 210 additions & 163 deletions src/libraries/System.Private.CoreLib/src/System/Numerics/Matrix4x4.cs

Large diffs are not rendered by default.

122 changes: 65 additions & 57 deletions src/libraries/System.Private.CoreLib/src/System/Numerics/Plane.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,54 @@

namespace System.Numerics
{
/// <summary>A structure encapsulating a 3D Plane</summary>
/// <summary>Represents a plane in three-dimensional space.</summary>
/// <remarks><format type="text/markdown"><![CDATA[
/// [!INCLUDE[vectors-are-rows-paragraph](~/includes/system-numerics-vectors-are-rows.md)]
/// ]]></format></remarks>
[Intrinsic]
public struct Plane : IEquatable<Plane>
{
private const float NormalizeEpsilon = 1.192092896e-07f; // smallest such that 1.0+NormalizeEpsilon != 1.0

/// <summary>The normal vector of the Plane.</summary>
/// <summary>The normal vector of the plane.</summary>
public Vector3 Normal;

/// <summary>The distance of the Plane along its normal from the origin.</summary>
/// <summary>The distance of the plane along its normal from the origin.</summary>
public float D;

/// <summary>Constructs a Plane from the X, Y, and Z components of its normal, and its distance from the origin on that normal.</summary>
/// <param name="x">The X-component of the normal.</param>
/// <param name="y">The Y-component of the normal.</param>
/// <param name="z">The Z-component of the normal.</param>
/// <param name="d">The distance of the Plane along its normal from the origin.</param>
/// <summary>Creates a <see cref="System.Numerics.Plane" /> object from the X, Y, and Z components of its normal, and its distance from the origin on that normal.</summary>
/// <param name="x">The X component of the normal.</param>
/// <param name="y">The Y component of the normal.</param>
/// <param name="z">The Z component of the normal.</param>
/// <param name="d">The distance of the plane along its normal from the origin.</param>
public Plane(float x, float y, float z, float d)
{
Normal = new Vector3(x, y, z);
D = d;
}

/// <summary>Constructs a Plane from the given normal and distance along the normal from the origin.</summary>
/// <param name="normal">The Plane's normal vector.</param>
/// <param name="d">The Plane's distance from the origin along its normal vector.</param>
/// <summary>Creates a <see cref="System.Numerics.Plane" /> object from a specified normal and the distance along the normal from the origin.</summary>
/// <param name="normal">The plane's normal vector.</param>
/// <param name="d">The plane's distance from the origin along its normal vector.</param>
public Plane(Vector3 normal, float d)
{
Normal = normal;
D = d;
}

/// <summary>Constructs a Plane from the given Vector4.</summary>
/// <param name="value">A vector whose first 3 elements describe the normal vector,
/// and whose W component defines the distance along that normal from the origin.</param>
/// <summary>Creates a <see cref="System.Numerics.Plane" /> object from a specified four-dimensional vector.</summary>
/// <param name="value">A vector whose first three elements describe the normal vector, and whose <see cref="System.Numerics.Vector4.W" /> defines the distance along that normal from the origin.</param>
public Plane(Vector4 value)
{
Normal = new Vector3(value.X, value.Y, value.Z);
D = value.W;
}

/// <summary>Creates a Plane that contains the three given points.</summary>
/// <param name="point1">The first point defining the Plane.</param>
/// <param name="point2">The second point defining the Plane.</param>
/// <param name="point3">The third point defining the Plane.</param>
/// <returns>The Plane containing the three points.</returns>
/// <summary>Creates a <see cref="System.Numerics.Plane" /> object that contains three specified points.</summary>
/// <param name="point1">The first point defining the plane.</param>
/// <param name="point2">The second point defining the plane.</param>
/// <param name="point3">The third point defining the plane.</param>
/// <returns>The plane containing the three points.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Plane CreateFromVertices(Vector3 point1, Vector3 point2, Vector3 point3)
{
Expand Down Expand Up @@ -100,9 +102,9 @@ public static Plane CreateFromVertices(Vector3 point1, Vector3 point2, Vector3 p
}
}

/// <summary>Calculates the dot product of a Plane and Vector4.</summary>
/// <param name="plane">The Plane.</param>
/// <param name="value">The Vector4.</param>
/// <summary>Calculates the dot product of a plane and a 4-dimensional vector.</summary>
/// <param name="plane">The plane.</param>
/// <param name="value">The four-dimensional vector.</param>
/// <returns>The dot product.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Dot(Plane plane, Vector4 value)
Expand All @@ -113,10 +115,10 @@ public static float Dot(Plane plane, Vector4 value)
plane.D * value.W;
}

/// <summary>Returns the dot product of a specified Vector3 and the normal vector of this Plane plus the distance (D) value of the Plane.</summary>
/// <summary>Returns the dot product of a specified three-dimensional vector and the normal vector of this plane plus the distance (<see cref="System.Numerics.Plane.D" />) value of the plane.</summary>
/// <param name="plane">The plane.</param>
/// <param name="value">The Vector3.</param>
/// <returns>The resulting value.</returns>
/// <param name="value">The 3-dimensional vector.</param>
/// <returns>The dot product.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float DotCoordinate(Plane plane, Vector3 value)
{
Expand All @@ -133,10 +135,10 @@ public static float DotCoordinate(Plane plane, Vector3 value)
}
}

/// <summary>Returns the dot product of a specified Vector3 and the Normal vector of this Plane.</summary>
/// <summary>Returns the dot product of a specified three-dimensional vector and the <see cref="System.Numerics.Plane.Normal" /> vector of this plane.</summary>
/// <param name="plane">The plane.</param>
/// <param name="value">The Vector3.</param>
/// <returns>The resulting dot product.</returns>
/// <param name="value">The three-dimensional vector.</param>
/// <returns>The dot product.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float DotNormal(Plane plane, Vector3 value)
{
Expand All @@ -152,9 +154,9 @@ public static float DotNormal(Plane plane, Vector3 value)
}
}

/// <summary>Creates a new Plane whose normal vector is the source Plane's normal vector normalized.</summary>
/// <param name="value">The source Plane.</param>
/// <returns>The normalized Plane.</returns>
/// <summary>Creates a new <see cref="System.Numerics.Plane" /> object whose normal vector is the source plane's normal vector normalized.</summary>
/// <param name="value">The source plane.</param>
/// <returns>The normalized plane.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Plane Normalize(Plane value)
{
Expand Down Expand Up @@ -190,11 +192,11 @@ public static Plane Normalize(Plane value)
}
}

/// <summary>Transforms a normalized Plane by a Matrix.</summary>
/// <param name="plane"> The normalized Plane to transform.
/// This Plane must already be normalized, so that its Normal vector is of unit length, before this method is called.</param>
/// <param name="matrix">The transformation matrix to apply to the Plane.</param>
/// <returns>The transformed Plane.</returns>
/// <summary>Transforms a normalized plane by a 4x4 matrix.</summary>
/// <param name="plane">The normalized plane to transform.</param>
/// <param name="matrix">The transformation matrix to apply to <paramref name="plane" />.</param>
/// <returns>The transformed plane.</returns>
/// <remarks><paramref name="plane" /> must already be normalized so that its <see cref="System.Numerics.Plane.Normal" /> vector is of unit length before this method is called.</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Plane Transform(Plane plane, Matrix4x4 matrix)
{
Expand All @@ -209,11 +211,11 @@ public static Plane Transform(Plane plane, Matrix4x4 matrix)
x * m.M41 + y * m.M42 + z * m.M43 + w * m.M44);
}

/// <summary> Transforms a normalized Plane by a Quaternion rotation.</summary>
/// <param name="plane"> The normalized Plane to transform.
/// This Plane must already be normalized, so that its Normal vector is of unit length, before this method is called.</param>
/// <param name="rotation">The Quaternion rotation to apply to the Plane.</param>
/// <returns>A new Plane that results from applying the rotation.</returns>
/// <summary>Transforms a normalized plane by a Quaternion rotation.</summary>
/// <param name="plane">The normalized plane to transform.</param>
/// <param name="rotation">The Quaternion rotation to apply to the plane.</param>
/// <returns>A new plane that results from applying the Quaternion rotation.</returns>
/// <remarks><paramref name="plane" /> must already be normalized so that its <see cref="System.Numerics.Plane.Normal" /> vector is of unit length before this method is called.</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Plane Transform(Plane plane, Quaternion rotation)
{
Expand Down Expand Up @@ -253,10 +255,12 @@ public static Plane Transform(Plane plane, Quaternion rotation)
plane.D);
}

/// <summary>Returns a boolean indicating whether the two given Planes are equal.</summary>
/// <param name="value1">The first Plane to compare.</param>
/// <param name="value2">The second Plane to compare.</param>
/// <returns>True if the Planes are equal; False otherwise.</returns>
/// <summary>Returns a value that indicates whether two planes are equal.</summary>
/// <param name="value1">The first plane to compare.</param>
/// <param name="value2">The second plane to compare.</param>
/// <returns><see langword="true" /> if <paramref name="value1" /> and <paramref name="value2" /> are equal; otherwise, <see langword="false" />.</returns>
/// <remarks>Two <see cref="System.Numerics.Plane" /> objects are equal if their <see cref="System.Numerics.Plane.Normal" /> and <see cref="System.Numerics.Plane.D" /> fields are equal.
/// The <see cref="System.Numerics.Plane.op_Equality" /> method defines the operation of the equality operator for <see cref="System.Numerics.Plane" /> objects.</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(Plane value1, Plane value2)
{
Expand All @@ -266,28 +270,31 @@ public static Plane Transform(Plane plane, Quaternion rotation)
value1.D == value2.D);
}

/// <summary>Returns a boolean indicating whether the two given Planes are not equal.</summary>
/// <param name="value1">The first Plane to compare.</param>
/// <param name="value2">The second Plane to compare.</param>
/// <returns>True if the Planes are not equal; False if they are equal.</returns>
/// <summary>Returns a value that indicates whether two planes are not equal.</summary>
/// <param name="value1">The first plane to compare.</param>
/// <param name="value2">The second plane to compare.</param>
/// <returns><see langword="true" /> if <paramref name="value1" /> and <paramref name="value2" /> are not equal; otherwise, <see langword="false" />.</returns>
/// <remarks>The <see cref="System.Numerics.Plane.op_Inequality" /> method defines the operation of the inequality operator for <see cref="System.Numerics.Plane" /> objects.</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(Plane value1, Plane value2)
{
return !(value1 == value2);
}

/// <summary>Returns a boolean indicating whether the given Object is equal to this Plane instance.</summary>
/// <param name="obj">The Object to compare against.</param>
/// <returns>True if the Object is equal to this Plane; False otherwise.</returns>
/// <summary>Returns a value that indicates whether this instance and a specified object are equal.</summary>
/// <param name="obj">The object to compare with the current instance.</param>
/// <returns><see langword="true" /> if the current instance and <paramref name="obj" /> are equal; otherwise, <see langword="false" />. If <paramref name="obj" /> is <see langword="null" />, the method returns <see langword="false" />.</returns>
/// <remarks>The current instance and <paramref name="obj" /> are equal if <paramref name="obj" /> is a <see cref="System.Numerics.Plane" /> object and their <see cref="System.Numerics.Plane.Normal" /> and <see cref="System.Numerics.Plane.D" /> fields are equal.</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override readonly bool Equals([NotNullWhen(true)] object? obj)
{
return (obj is Plane other) && Equals(other);
}

/// <summary>Returns a boolean indicating whether the given Plane is equal to this Plane instance.</summary>
/// <param name="other">The Plane to compare this instance to.</param>
/// <returns>True if the other Plane is equal to this instance; False otherwise.</returns>
/// <summary>Returns a value that indicates whether this instance and another plane object are equal.</summary>
/// <param name="other">The other plane.</param>
/// <returns><see langword="true" /> if the two planes are equal; otherwise, <see langword="false" />.</returns>
/// <remarks>Two <see cref="System.Numerics.Plane" /> objects are equal if their <see cref="System.Numerics.Plane.Normal" /> and <see cref="System.Numerics.Plane.D" /> fields are equal.</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly bool Equals(Plane other)
{
Expand All @@ -311,8 +318,9 @@ public override readonly int GetHashCode()
return Normal.GetHashCode() + D.GetHashCode();
}

/// <summary>Returns a String representing this Plane instance.</summary>
/// <returns>The string representation.</returns>
/// <summary>Returns the string representation of this plane object.</summary>
/// <returns>A string that represents this <see cref="System.Numerics.Plane" /> object.</returns>
/// <remarks>The string representation of a <see cref="System.Numerics.Plane" /> object use the formatting conventions of the current culture to format the numeric values in the returned string. For example, a <see cref="System.Numerics.Plane" /> object whose string representation is formatted by using the conventions of the en-US culture might appear as <c>{Normal:&lt;1.1, 2.2, 3.3&gt; D:4.4}</c>.</remarks>
public override readonly string ToString()
{
CultureInfo ci = CultureInfo.CurrentCulture;
Expand Down
Loading