Skip to content
This repository was archived by the owner on Mar 30, 2019. It is now read-only.

Commit 5852eda

Browse files
committed
[Mathematics] Add per component absolute value for vector3
1 parent b8de7a7 commit 5852eda

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

Source/SharpDX.Mathematics/Vector3.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,31 @@ public static Vector3 Negate(Vector3 value)
513513
return new Vector3(-value.X, -value.Y, -value.Z);
514514
}
515515

516+
/// <summary>
517+
/// Returns per component absolute value of a vector
518+
/// </summary>
519+
/// <param name="value">Input vector</param>
520+
/// <param name="result">When the method completes, contains a vector with each component being the absolute value of the input component</param>
521+
public static void Abs(ref Vector3 value, out Vector3 result)
522+
{
523+
result = new Vector3(value.X > 0.0f ? value.X : -value.X,
524+
value.Y > 0.0f ? value.Y : -value.Y,
525+
value.Z > 0.0f ? value.Z : -value.Z);
526+
}
527+
528+
/// <summary>
529+
/// Returns per component absolute value of a vector
530+
/// </summary>
531+
/// <param name="value">Input vector</param>
532+
/// <returns>A vector with each component being the absolute value of the input component</returns>
533+
public static Vector3 Abs(Vector3 value)
534+
{
535+
return new Vector3(
536+
value.X > 0.0f ? value.X : -value.X,
537+
value.Y > 0.0f ? value.Y : -value.Y,
538+
value.Z > 0.0f ? value.Z : -value.Z);
539+
}
540+
516541
/// <summary>
517542
/// Returns a <see cref="Vector3"/> containing the 3D Cartesian coordinates of a point specified in Barycentric coordinates relative to a 3D triangle.
518543
/// </summary>

0 commit comments

Comments
 (0)