From 267c450677c055252bceeade534504ddd8569c8a Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Wed, 30 Nov 2022 18:40:02 +0000 Subject: [PATCH] Add helper methods to complement Vector3d operators --- VpSharp/src/Vector3d.cs | 87 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/VpSharp/src/Vector3d.cs b/VpSharp/src/Vector3d.cs index cca7bd6..64043f1 100644 --- a/VpSharp/src/Vector3d.cs +++ b/VpSharp/src/Vector3d.cs @@ -285,6 +285,17 @@ public struct Vector3d : IEquatable, IFormattable ); } + /// + /// Adds two vectors together. + /// + /// The first source vector. + /// The second source vector. + /// The summed vector. + public static Vector3d Add(in Vector3d left, in Vector3d right) + { + return left + right; + } + /// /// Restricts a vector between a minimum and maximum value. /// @@ -337,6 +348,28 @@ public struct Vector3d : IEquatable, IFormattable return Dot(difference, difference); } + /// + /// Divides the first vector by the second. + /// + /// The first source vector. + /// The second source vector. + /// The vector resulting from the division. + public static Vector3d Divide(in Vector3d left, in Vector3d right) + { + return left / right; + } + + /// + /// Divides the vector by the given scalar. + /// + /// The vector value. + /// The scalar value. + /// The vector resulting from the division. + public static Vector3d Divide(in Vector3d left, double right) + { + return left / right; + } + /// /// Returns the dot product of two vectors. /// @@ -405,6 +438,49 @@ public struct Vector3d : IEquatable, IFormattable ); } + /// + /// Multiples two vectors together. + /// + /// The first source vector. + /// The second source vector. + /// The product vector. + public static Vector3d Multiply(in Vector3d left, in Vector3d right) + { + return left * right; + } + + /// + /// Multiples a vector by the given scalar. + /// + /// The vector value. + /// The scalar value. + /// The scaled vector. + public static Vector3d Multiply(in Vector3d left, double right) + { + return left * right; + } + + /// + /// Multiples a vector by the given scalar. + /// + /// The scalar value. + /// The vector value. + /// The scaled vector. + public static Vector3d Multiply(double left, in Vector3d right) + { + return left * right; + } + + /// + /// Negates a given vector. + /// + /// The source vector. + /// The negated vector. + public static Vector3d Negate(in Vector3d value) + { + return -value; + } + /// /// Returns a vector with the same direction as the given vector, but with a length of 1. /// @@ -442,6 +518,17 @@ public struct Vector3d : IEquatable, IFormattable ); } + /// + /// Subtracts the second vector from the first. + /// + /// The first source vector. + /// The second source vector. + /// The difference vector. + public static Vector3d Subtract(in Vector3d left, in Vector3d right) + { + return left - right; + } + /// /// Copies the contents of the vector into the given array. ///