### Using Unity Mathematics in C# Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/manual/getting-started This snippet demonstrates how to include the Unity Mathematics library in your C# code. It shows the necessary 'using' directive and a basic example of initializing and manipulating float3 vectors using functions like 'normalize' and 'dot'. ```csharp using static Unity.Mathematics.math; namespace MyNamespace { using Unity.Mathematics; // ... var v1 = float3(1,2,3); var v2 = float3(4,5,6); v1 = normalize(v1); v2 = normalize(v2); var v3 = dot(v1, v2); // ... } ``` -------------------------------- ### Get Zero int3x2 Matrix - C# Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.int3x2 This snippet demonstrates how to access the static 'zero' field of the int3x2 struct in Unity.Mathematics to obtain a matrix initialized with all zeros. This is useful for resetting matrices or initializing them to a known neutral state. ```csharp using Unity.Mathematics; public class ExampleClass { void Start() { int3x2 zeroMatrix = int3x2.zero; // zeroMatrix will be a 3x2 matrix with all elements as 0 } } ``` -------------------------------- ### Generate Random Numbers with Unity Mathematics Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/manual/random-numbers Demonstrates how to initialize a `Random` struct with a seed and generate random float values. It shows how to get a default random float between [0, 1) and a random float within a specified range [-5, 5). ```csharp void RandomNumberUnityMathematics() { // Choose some non-zero seed and set up the random number generator state. uint seed = 1; Unity.Mathematics.Random rng = new Unity.Mathematics.Random(seed); // [0, 1) exclusive float randomFloat1 = rng.NextFloat(); // [-5, 5) exclusive float randomFloat2 = rng.NextFloat(-5.0f, 5.0f); } ``` -------------------------------- ### Accessing Zero Initialization for double4x3 in C# Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.double4x3 This snippet demonstrates how to access the static readonly 'zero' field of the double4x3 struct. This field provides a pre-initialized matrix where all elements are set to zero, useful for starting calculations or as a default value. No external dependencies are required beyond the Unity.Mathematics library. ```csharp using Unity.Mathematics; public class ExampleClass { public void ExampleMethod() { // Get a zero-initialized 4x3 double matrix double4x3 zeroMatrix = double4x3.zero; // You can now use zeroMatrix for calculations or as a default value // For example, printing the matrix (requires a helper function or direct access to elements) // For demonstration, let's just confirm its existence. if (zeroMatrix.Equals(new double4x3(0.0))) { // The matrix is indeed all zeros } } } ``` -------------------------------- ### Unity C# uint2x4 Matrix Modulus Operator Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.uint2x4 Provides C# code examples for the componentwise modulus operation (%) on uint2x4 matrices using the Unity Mathematics package. This includes operations between two uint2x4 matrices and between a uint2x4 matrix and a uint value. ```csharp using Unity.Mathematics; public class MatrixModulusExample { public static void Example() { // Example 1: uint2x4 % uint2x4 uint2x4 matrixA = new uint2x4(10, 20, 30, 40, 50, 60, 70, 80); uint2x4 matrixB = new uint2x4(3, 5, 7, 2, 4, 6, 8, 10); uint2x4 result1 = matrixA % matrixB; // Example 2: uint2x4 % uint uint scalar = 5; uint2x4 result2 = matrixA % scalar; // Example 3: uint % uint2x4 uint2x4 result3 = scalar % matrixB; } } ``` -------------------------------- ### Get Zero int2x2 Matrix - C# Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.int2x2 This C# code snippet demonstrates how to access the static readonly 'zero' field of the int2x2 struct from the Unity.Mathematics library. This field provides a convenient way to get a 2x2 integer matrix with all elements initialized to zero. No specific input is required, and the output is the int2x2 zero matrix. ```csharp using Unity.Mathematics; public class Example { public void ShowZeroMatrix() { int2x2 zeroMatrix = int2x2.zero; // You can now use zeroMatrix, for example, print it to the console: // Debug.Log(zeroMatrix); } } ``` -------------------------------- ### Unity.Mathematics.half.zero Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.half Provides information about the `zero` field in the `Unity.Mathematics` namespace. ```APIDOC ## Field zero ### Description Represents the half-precision floating-point value zero. ### Namespace Unity.Mathematics ### Assembly Unity.Mathematics.dll ### Syntax ```csharp public static readonly half zero ``` ### Returns - **half**: The value zero. ``` -------------------------------- ### half2.ToString(string, IFormatProvider) Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.half2 Returns a string representation of the half2 using a specified format and culture-specific format information. ```APIDOC ## GET /websites/unity3d_packages_com_unity_mathematics_1_3/ToString/formatted ### Description Returns a string representation of the half2 using a specified format and culture-specific format information. ### Method GET ### Endpoint /websites/unity3d_packages_com_unity_mathematics_1_3/ToString/formatted ### Parameters #### Query Parameters - **format** (string) - Required - The format string to use during string formatting. - **formatProvider** (IFormatProvider) - Required - The format provider to use during string formatting. ### Request Example ```json { "format": "F2", "formatProvider": "en-US" } ``` ### Response #### Success Response (200) - **result** (string) - String representation of the half2. #### Response Example ```json { "result": "(1.00, 2.50)" } ``` ``` -------------------------------- ### Accessing uint4.zero in C# Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.uint4 This snippet demonstrates how to access the static readonly uint4.zero field in C#. It shows its declaration and a simple usage example. ```csharp using Unity.Mathematics; public class ExampleClass { public void ExampleMethod() { // Accessing the zero uint4 value uint4 zeroValue = uint4.zero; // Example usage: initializing a vector to zero uint4 vector = uint4.zero; // You can also use it in operations, for example: // uint4 anotherVector = vector + uint4.one; } } ``` -------------------------------- ### Create a 4x4 Matrix with Unity Mathematics Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/manual/4x4-matrices Demonstrates the creation of a 4x4 transformation matrix (`float4x4`) using Unity's Mathematics library. Matrices can be initialized with a single value for all elements or by setting each of the 16 elements individually. ```csharp void Build4x4UnityMathematics() { var c0 = new float4(1.0f, 0.0f, 0.0f, 0.0f); var c1 = new float4(0.0f, 1.0f, 0.0f, 0.0f); var c2 = new float4(0.0f, 0.0f, 1.0f, 0.0f); var c3 = new float4(0.0f, 0.0f, 0.0f, 1.0f); var m = new float4x4(c0, c1, c2, c3); } ``` -------------------------------- ### Plane Normal Property Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.Geometry.Plane This section describes the `Normal` property of the `Plane` struct, which allows getting and setting the normal vector of the plane. ```APIDOC ## GET/SET Plane.Normal ### Description Get or set the normal vector of the plane. It is assumed that the normal is unit length. ### Method GET/SET ### Endpoint N/A (This is a property of a struct, not a REST endpoint) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```csharp // Getting the normal float3 planeNormal = myPlane.Normal; // Setting the normal (ensure it's unit length) myPlane.Normal = new float3(0, 1, 0); // If the normal is not unit length, normalize the plane // myPlane.Normalize(myPlane); ``` ### Response #### Success Response (Property Value) - **Normal** (float3) - The normal vector of the plane. #### Response Example ```json { "Normal": [0.0, 1.0, 0.0] } ``` ### Remarks If you set a new plane such that Ax + By + Cz + Dw = 0 but (A, B, C) is not unit length, then you must normalize the plane by calling `Normalize(Plane)`. ``` -------------------------------- ### Struct uint4x4 Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics A 4x4 matrix of uints. ```APIDOC ## Struct uint4x4 A 4x4 matrix of uints. ### Namespace Unity.Mathematics ### Assembly Unity.Mathematics.dll ### Syntax ```csharp [Serializable] public struct uint4x4 : IEquatable, IFormattable ``` ### Constructors * **uint4x4(bool)**: Constructs a uint4x4 matrix from a single bool value by converting it to uint and assigning it to every component. * **uint4x4(double)**: Constructs a uint4x4 matrix from a single double value by converting it to uint and assigning it to every component. * **uint4x4(int)**: Constructs a uint4x4 matrix from a single int value by converting it to uint and assigning it to every component. * **uint4x4(float)**: Constructs a uint4x4 matrix from a single float value by converting it to uint and assigning it to every component. * **uint4x4(uint)**: Constructs a uint4x4 matrix from a single uint value by assigning it to every component. * **uint4x4(uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint)**: Constructs a uint4x4 matrix from 16 uint values given in row-major order. * **uint4x4(bool4x4)**: Constructs a uint4x4 matrix from a bool4x4 matrix by componentwise conversion. * **uint4x4(double4x4)**: Constructs a uint4x4 matrix from a double4x4 matrix by componentwise conversion. * **uint4x4(float4x4)**: Constructs a uint4x4 matrix from a float4x4 matrix by componentwise conversion. * **uint4x4(int4x4)**: Constructs a uint4x4 matrix from a int4x4 matrix by componentwise conversion. * **uint4x4(uint4, uint4, uint4, uint4)**: Constructs a uint4x4 matrix from four uint4 vectors. ### Fields * **c0** (uint4): Column 0 of the matrix. * **c1** (uint4): Column 1 of the matrix. * **c2** (uint4): Column 2 of the matrix. * **c3** (uint4): Column 3 of the matrix. * **identity** (uint4x4): uint4x4 identity transform. * **zero** (uint4x4): uint4x4 zero value. ### Properties * **this[int]** (uint4): Returns the uint4 element at a specified index. ### Methods * **Equals(object)**: Returns true if the uint4x4 is equal to a given uint4x4, false otherwise. * **Equals(uint4x4)**: Returns true if the uint4x4 is equal to a given uint4x4, false otherwise. * **GetHashCode()**: Returns a hash code for the uint4x4. * **ToString()**: Returns a string representation of the uint4x4. * **ToString(string, IFormatProvider)**: Returns a string representation of the uint4x4 using a specified format and culture-specific format information. ``` -------------------------------- ### Get Half Zero Value (Unity.Mathematics) Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.half Retrieves the zero value for half-precision floating-point numbers using the Unity.Mathematics library. This is a static readonly field, meaning it is constant and accessible directly via the type. ```csharp using Unity.Mathematics; // Access the zero value for half-precision floats half zeroValue = half.zero; // You can use this value in calculations or comparisons if (someHalfValue == half.zero) { // Handle the case where the value is zero } ``` -------------------------------- ### Get Zero int3x4 Matrix - C# Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.int3x4 Accesses the static readonly `zero` field of the `int3x4` struct to obtain a 3x4 integer matrix filled with zeros. This is useful for initializing matrices or as a default value. ```csharp using Unity.Mathematics; public class Example { public void GetZeroMatrix() { int3x4 zeroMatrix = int3x4.zero; // Now zeroMatrix is a 3x4 matrix with all elements as 0. } } ``` -------------------------------- ### Hashing Functions Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.math This section provides documentation for various overloaded `hash` functions that compute a uint hash code for different Unity Math types. ```APIDOC ## hash(bool4x3) ### Description Returns a uint hash code of a bool4x3 matrix. ### Method GET (assumed, as it's a function call) ### Endpoint N/A (This is a static method, not a REST endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **v** (bool4x3) - Required - Matrix value to hash. ### Request Example ```json { "v": [[true, true, true, true], [true, true, true, true], [true, true, true, true]] } ``` ### Response #### Success Response (200) * **hash** (uint) - uint hash of the argument. #### Response Example ```json { "hash": 1234567890 } ``` ## hash(double2x4) ### Description Returns a uint hash code of a double2x4 matrix. ### Method GET (assumed, as it's a function call) ### Endpoint N/A (This is a static method, not a REST endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **v** (double2x4) - Required - Matrix value to hash. ### Request Example ```json { "v": [[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]] } ``` ### Response #### Success Response (200) * **hash** (uint) - uint hash of the argument. #### Response Example ```json { "hash": 9876543210 } ``` ## hash(bool3) ### Description Returns a uint hash code of a bool3 vector. ### Method GET (assumed, as it's a function call) ### Endpoint N/A (This is a static method, not a REST endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **v** (bool3) - Required - Vector value to hash. ### Request Example ```json { "v": [true, false, true] } ``` ### Response #### Success Response (200) * **hash** (uint) - uint hash of the argument. #### Response Example ```json { "hash": 1122334455 } ``` ## hash(uint3x2) ### Description Returns a uint hash code of a uint3x2 matrix. ### Method GET (assumed, as it's a function call) ### Endpoint N/A (This is a static method, not a REST endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **v** (uint3x2) - Required - Matrix value to hash. ### Request Example ```json { "v": [[1, 2, 3], [4, 5, 6]] } ``` ### Response #### Success Response (200) * **hash** (uint) - uint hash of the argument. #### Response Example ```json { "hash": 6677889900 } ``` ## hash(int2x4) ### Description Returns a uint hash code of a int2x4 matrix. ### Method GET (assumed, as it's a function call) ### Endpoint N/A (This is a static method, not a REST endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **v** (int2x4) - Required - Matrix value to hash. ### Request Example ```json { "v": [[1, 2, 3, 4], [5, 6, 7, 8]] } ``` ### Response #### Success Response (200) * **hash** (uint) - uint hash of the argument. #### Response Example ```json { "hash": 1010101010 } ``` ## hash(bool2x4) ### Description Returns a uint hash code of a bool2x4 matrix. ### Method GET (assumed, as it's a function call) ### Endpoint N/A (This is a static method, not a REST endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **v** (bool2x4) - Required - Matrix value to hash. ### Request Example ```json { "v": [[true, true, true, true], [false, false, false, false]] } ``` ### Response #### Success Response (200) * **hash** (uint) - uint hash of the argument. #### Response Example ```json { "hash": 2020202020 } ``` ## hash(double3x3) ### Description Returns a uint hash code of a double3x3 matrix. ### Method GET (assumed, as it's a function call) ### Endpoint N/A (This is a static method, not a REST endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **v** (double3x3) - Required - Matrix value to hash. ### Request Example ```json { "v": [[1.1, 1.2, 1.3], [2.1, 2.2, 2.3], [3.1, 3.2, 3.3]] } ``` ### Response #### Success Response (200) * **hash** (uint) - uint hash of the argument. #### Response Example ```json { "hash": 3030303030 } ``` ## hash(float4x3) ### Description Returns a uint hash code of a float4x3 matrix. ### Method GET (assumed, as it's a function call) ### Endpoint N/A (This is a static method, not a REST endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **v** (float4x3) - Required - Matrix value to hash. ### Request Example ```json { "v": [[1.0f, 1.1f, 1.2f], [2.0f, 2.1f, 2.2f], [3.0f, 3.1f, 3.2f], [4.0f, 4.1f, 4.2f]] } ``` ### Response #### Success Response (200) * **hash** (uint) - uint hash of the argument. #### Response Example ```json { "hash": 4040404040 } ``` ## hash(bool2x3) ### Description Returns a uint hash code of a bool2x3 matrix. ### Method GET (assumed, as it's a function call) ### Endpoint N/A (This is a static method, not a REST endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **v** (bool2x3) - Required - Matrix value to hash. ### Request Example ```json { "v": [[true, false, true], [false, true, false]] } ``` ### Response #### Success Response (200) * **hash** (uint) - uint hash of the argument. #### Response Example ```json { "hash": 5050505050 } ``` ## hash(float3x4) ### Description Returns a uint hash code of a float3x4 matrix. ### Method GET (assumed, as it's a function call) ### Endpoint N/A (This is a static method, not a REST endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **v** (float3x4) - Required - Matrix value to hash. ### Request Example ```json { "v": [[1.0f, 1.1f, 1.2f, 1.3f], [2.0f, 2.1f, 2.2f, 2.3f], [3.0f, 3.1f, 3.2f, 3.3f]] } ``` ### Response #### Success Response (200) * **hash** (uint) - uint hash of the argument. #### Response Example ```json { "hash": 6060606060 } ``` ## hash(float2x4) ### Description Returns a uint hash code of a float2x4 matrix. ### Method GET (assumed, as it's a function call) ### Endpoint N/A (This is a static method, not a REST endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **v** (float2x4) - Required - Matrix value to hash. ### Request Example ```json { "v": [[1.0f, 1.1f, 1.2f, 1.3f], [2.0f, 2.1f, 2.2f, 2.3f]] } ``` ### Response #### Success Response (200) * **hash** (uint) - uint hash of the argument. #### Response Example ```json { "hash": 7070707070 } ``` ## hash(double4) ### Description Returns a uint hash code of a double4 vector. ### Method GET (assumed, as it's a function call) ### Endpoint N/A (This is a static method, not a REST endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **v** (double4) - Required - Vector value to hash. ### Request Example ```json { "v": [1.1, 2.2, 3.3, 4.4] } ``` ### Response #### Success Response (200) * **hash** (uint) - uint hash of the argument. #### Response Example ```json { "hash": 8080808080 } ``` ## hash(float2x2) ### Description Returns a uint hash code of a float2x2 matrix. ### Method GET (assumed, as it's a function call) ### Endpoint N/A (This is a static method, not a REST endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **v** (float2x2) - Required - Matrix value to hash. ### Request Example ```json { "v": [[1.0f, 1.1f], [2.0f, 2.1f]] } ``` ### Response #### Success Response (200) * **hash** (uint) - uint hash of the argument. #### Response Example ```json { "hash": 9090909090 } ``` ## hash(int3x3) ### Description Returns a uint hash code of a int3x3 matrix. ### Method GET (assumed, as it's a function call) ### Endpoint N/A (This is a static method, not a REST endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **v** (int3x3) - Required - Matrix value to hash. ### Request Example ```json { "v": [[1, 2, 3], [4, 5, 6], [7, 8, 9]] } ``` ### Response #### Success Response (200) * **hash** (uint) - uint hash of the argument. #### Response Example ```json { "hash": 1000000001 } ``` ## hash(float2x3) ### Description Returns a uint hash code of a float2x3 matrix. ### Method GET (assumed, as it's a function call) ### Endpoint N/A (This is a static method, not a REST endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **v** (float2x3) - Required - Matrix value to hash. ### Request Example ```json { "v": [[1.0f, 1.1f, 1.2f], [2.0f, 2.1f, 2.2f]] } ``` ### Response #### Success Response (200) * **hash** (uint) - uint hash of the argument. #### Response Example ```json { "hash": 1111111111 } ``` ## hash(half) ### Description Returns a uint hash code of a half value. ### Method GET (assumed, as it's a function call) ### Endpoint N/A (This is a static method, not a REST endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **v** (half) - Required - The half value to hash. ### Request Example ```json { "v": 0.5 } ``` ### Response #### Success Response (200) * **hash** (uint) - The computed hash code of the half value. #### Response Example ```json { "hash": 1212121212 } ``` ## hash(uint2x2) ### Description Returns a uint hash code of a uint2x2 matrix. ### Method GET (assumed, as it's a function call) ### Endpoint N/A (This is a static method, not a REST endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **v** (uint2x2) - Required - Matrix value to hash. ### Request Example ```json { "v": [[1, 2], [3, 4]] } ``` ### Response #### Success Response (200) * **hash** (uint) - uint hash of the argument. #### Response Example ```json { "hash": 1313131313 } ``` ``` -------------------------------- ### AffineTransform.ToString() Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.AffineTransform Returns a string representation of the AffineTransform. ```APIDOC ## AffineTransform.ToString() ### Description Returns a string representation of the AffineTransform. ### Method GET ### Endpoint N/A (Instance method) ### Parameters None ### Request Example ```csharp AffineTransform transform = AffineTransform.Identity; string representation = transform.ToString(); Debug.Log(representation); ``` ### Response #### Success Response (200) - **string** - String representation of the value. #### Response Example ``` "(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)" ``` ``` -------------------------------- ### Get Unity.Mathematics.double3x4 Zero Value Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.double3x4 This snippet demonstrates how to access the static readonly `zero` field of the `double3x4` struct in Unity.Mathematics. This field returns a `double3x4` matrix where all elements are initialized to 0.0. It requires the Unity.Mathematics assembly. ```csharp using Unity.Mathematics; public class Example { public void GetZeroMatrix() { double3x4 zeroMatrix = double3x4.zero; // zeroMatrix will be a 3x4 matrix with all elements set to 0.0 } } ``` -------------------------------- ### hash(bool3x2) Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.math Returns a uint hash code of a bool3x2 matrix. ```APIDOC ## hash(bool3x2) ### Description Returns a uint hash code of a bool3x2 matrix. ### Method Not applicable (static method). ### Endpoint Not applicable (static method). ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp bool3x2 matrix = new bool3x2(true, false, false, true, true, false); uint hashValue = Math.hash(matrix); ``` ### Response #### Success Response (200) - **uint**: uint hash of the argument. ``` -------------------------------- ### Format Half2 to String with Culture (Unity) Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.half2 Returns a string representation of the half2 using a specified format and culture-specific format information. This method implements IFormattable.ToString() and allows for customized output based on format strings and culture. ```csharp public string ToString(string format, IFormatProvider formatProvider) { // Implementation details for formatted string conversion } ``` -------------------------------- ### Get Default String Representation of AffineTransform (C#) Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.AffineTransform This method provides a basic string representation of an AffineTransform object. It is useful for debugging or logging purposes where a simple string output is sufficient. This method overrides the base ValueType.ToString() method. ```csharp public override string ToString() { // Implementation returns a string representation of the AffineTransform } ``` -------------------------------- ### Initialize double2x3 to Zero Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.double2x3 Demonstrates how to access and use the `zero` field to create a `double2x3` matrix with all elements set to zero. This is useful for initializing matrices or as a default value. ```csharp using Unity.Mathematics; public class ExampleScript : MonoBehaviour { void Start() { double2x3 zeroMatrix = double2x3.zero; // Now zeroMatrix is a 2x3 matrix with all elements set to 0.0 Debug.Log(zeroMatrix); } } ``` -------------------------------- ### hash(bool4x2) Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.math Returns a uint hash code of a bool4x2 matrix. ```APIDOC ## hash(bool4x2) ### Description Returns a uint hash code of a bool4x2 matrix. ### Method Not applicable (static method). ### Endpoint Not applicable (static method). ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp bool4x2 matrix = new bool4x2(true, false, false, true, true, false, false, true); uint hashValue = Math.hash(matrix); ``` ### Response #### Success Response (200) - **uint**: uint hash of the argument. ``` -------------------------------- ### Component-wise Multiplication of 4x4 Matrices in Unity Mathematics Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/manual/4x4-matrices Illustrates the behavior of the `*` operator for `float4x4` matrices in Unity Mathematics, which performs component-wise multiplication. This is contrasted with `UnityEngine`'s operator definition. The example shows multiplying an identity matrix with a scaled identity matrix. ```csharp void OperatorMultiply4x4UnityMathematics() { float4x4 result = f4x4_Ones * f4x4_HalfIdentity; // result: // 0.5, 0.0, 0.0, 0.0, // 0.0, 0.5, 0.0, 0.0, // 0.0, 0.0, 0.5, 0.0, // 0.0, 0.0, 0.0, 0.5 } ``` -------------------------------- ### bool3x3.GetHashCode Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.bool3x3 Returns a hash code for the bool3x3 struct. ```APIDOC ## GET bool3x3/GetHashCode ### Description Returns a hash code for the bool3x3. ### Method GET ### Endpoint /websites/unity3d_packages_com_unity_mathematics_1_3/bool3x3/GetHashCode ### Parameters #### Query Parameters - **`value`** (bool3x3) - Required - The bool3x3 value to get the hash code for. ### Response #### Success Response (200) - **`hash_code`** (int) - The computed hash code. #### Response Example ```json { "hash_code": 123456789 } ``` ``` -------------------------------- ### Vector Projection Functions (C#) Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/changelog/CHANGELOG Introduces math.project and math.projectsafe for vector projection. These functions are essential for geometric calculations, with projectsafe handling potential zero-length vectors. ```csharp /// /// Projects vector 'a' onto vector 'b'. /// /// The vector to project. /// The vector to project onto. /// The projected vector. public static float3 project(float3 a, float3 b) ``` ```csharp /// /// Projects vector 'a' onto vector 'b', returning zero if 'b' is zero. /// /// The vector to project. /// The vector to project onto. /// The projected vector, or zero if 'b' is zero. public static float3 projectsafe(float3 a, float3 b) ``` -------------------------------- ### Get a Zero half3 Vector in C# Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.half3 This snippet demonstrates how to access the predefined 'zero' field of the half3 struct in C#. This field provides a convenient way to obtain a half3 vector with all components set to 0, which is useful for initialization or comparison purposes. No external dependencies are required beyond the Unity.Mathematics namespace. ```csharp using Unity.Mathematics; public class ExampleClass { public void AccessZeroVector() { half3 zeroVector = half3.zero; // You can now use zeroVector, for example: // Debug.Log(zeroVector); } } ``` -------------------------------- ### Logarithm Base 2 Functions (C#) Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/changelog/CHANGELOG Introduces math.ceillog2 and math.floorlog2 for calculating the ceiling and floor of the base-2 logarithm of an integer. These are useful in bit manipulation and algorithm optimization. ```csharp /// /// Computes the ceiling of the base-2 logarithm of an integer. /// /// The input integer. /// The ceiling of the base-2 logarithm. public static int ceillog2(uint x) ``` ```csharp /// /// Computes the floor of the base-2 logarithm of an integer. /// /// The input integer. /// The floor of the base-2 logarithm. public static int floorlog2(uint x) ``` -------------------------------- ### Get Formatted String Representation of AffineTransform (C#) Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.AffineTransform This method allows for a custom string representation of an AffineTransform using a specified format string and culture-specific formatting information. This is useful for displaying the transform data in a user-friendly or standardized way, especially when dealing with different regional number and date formats. It implements the IFormattable interface. ```csharp public string ToString(string format, IFormatProvider formatProvider) { // Implementation returns a formatted string representation of the AffineTransform } ``` -------------------------------- ### Hash bool4x3 Matrix - Unity Mathematics Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.math Computes a uint hash code for a bool4x3 matrix. The input is a bool4x3 matrix, and the output is its uint hash. ```csharp public static uint hash(bool4x3 v) ``` -------------------------------- ### hash(bool3x3) Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.math Returns a uint hash code of a bool3x3 matrix. ```APIDOC ## hash(bool3x3) ### Description Returns a uint hash code of a bool3x3 matrix. ### Method Not applicable (static method). ### Endpoint Not applicable (static method). ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp bool3x3 matrix = new bool3x3(true, false, true, false, true, false, true, false, true); uint hashValue = Math.hash(matrix); ``` ### Response #### Success Response (200) - **uint**: uint hash of the argument. ``` -------------------------------- ### half2.ToString() Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.half2 Returns a string representation of the half2 value. ```APIDOC ## GET /websites/unity3d_packages_com_unity_mathematics_1_3/ToString ### Description Returns a string representation of the half2. ### Method GET ### Endpoint /websites/unity3d_packages_com_unity_mathematics_1_3/ToString ### Parameters #### Query Parameters - **format** (string) - Optional - The format string to use for formatting the half2 value. - **formatProvider** (IFormatProvider) - Optional - The format provider to use for formatting the half2 value. ### Request Example ```json { "description": "Example usage of ToString()" } ``` ### Response #### Success Response (200) - **result** (string) - A string representation of the half2 value. #### Response Example ```json { "result": "(1.0, 2.5)" } ``` ``` -------------------------------- ### Unity Mathematics int3x2.zero Field Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.int3x2 Details of the int3x2.zero field, representing a zero-initialized 3x2 integer matrix. ```APIDOC ## Field zero ### Description Represents a zero value for the `int3x2` type. ### Namespace Unity.Mathematics ### Assembly Unity.Mathematics.dll ### Syntax ```csharp public static readonly int3x2 zero ``` ### Returns - **int3x2**: A 3x2 matrix with all elements set to zero. ``` -------------------------------- ### hash(AffineTransform) Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.math Returns a uint hash code of an AffineTransform. ```APIDOC ## hash(AffineTransform) ### Description Returns a uint hash code of an AffineTransform. ### Method N/A (Static method) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (N/A) - **uint** - The hash code of the input AffineTransform. #### Response Example N/A ``` -------------------------------- ### hash(bool3x4) Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.math Returns a uint hash code of a bool3x4 matrix. ```APIDOC ## hash(bool3x4) ### Description Returns a uint hash code of a bool3x4 matrix. ### Method Not applicable (static method). ### Endpoint Not applicable (static method). ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp bool3x4 matrix = new bool3x4(true, false, true, false, false, true, false, true, false, true, false, true); uint hashValue = Math.hash(matrix); ``` ### Response #### Success Response (200) - **uint**: uint hash of the argument. ``` -------------------------------- ### hash(int2x3) Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.math Returns a uint hash code of a int2x3 matrix. ```APIDOC ## hash(int2x3) ### Description Returns a uint hash code of a int2x3 matrix. ### Method Not applicable (static method). ### Endpoint Not applicable (static method). ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp int2x3 matrix = new int2x3(1, 2, 3, 4, 5, 6); uint hashValue = Math.hash(matrix); ``` ### Response #### Success Response (200) - **uint**: uint hash of the argument. ``` -------------------------------- ### hash(bool4x4) Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.math Returns a uint hash code of a bool4x4 matrix. ```APIDOC ## hash(bool4x4) ### Description Returns a uint hash code of a bool4x4 matrix. ### Method Not applicable (static method). ### Endpoint Not applicable (static method). ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp bool4x4 matrix = new bool4x4(true, false, true, false, false, true, false, true, true, false, true, false, false, true, false, true); uint hashValue = Math.hash(matrix); ``` ### Response #### Success Response (200) - **uint**: uint hash of the argument. ``` -------------------------------- ### AffineTransform.ToString(string, IFormatProvider) Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.AffineTransform Returns a string representation of the AffineTransform using a specified format and culture-specific format information. ```APIDOC ## AffineTransform.ToString(string, IFormatProvider) ### Description Returns a string representation of the AffineTransform using a specified format and culture-specific format information. ### Method GET ### Endpoint N/A (Instance method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **format** (string) - Required - Format string to use during string formatting. - **formatProvider** (IFormatProvider) - Required - Format provider to use during string formatting. ### Request Example ```csharp using System.Globalization; AffineTransform transform = AffineTransform.Identity; string formattedString = transform.ToString("F2", CultureInfo.InvariantCulture); Debug.Log(formattedString); ``` ### Response #### Success Response (200) - **string** - String representation of the value. #### Response Example ``` "(1.00, 0.00, 0.00, 0.00, 1.00, 0.00, 0.00, 0.00, 1.00)" ``` ``` -------------------------------- ### Float3x3 Constructor from Float4x4 (C#) Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/changelog/CHANGELOG Introduces a constructor for float3x3 that accepts a float4x4 matrix. This allows for easier conversion and extraction of the 3x3 rotation/scale component from a 4x4 matrix. ```csharp /// /// Creates a float3x3 matrix from the top-left 3x3 portion of a float4x4 matrix. /// /// The float4x4 matrix. public float3x3(float4x4 m) ``` -------------------------------- ### hash(half2) Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.math Returns a uint hash code of a half2 vector. ```APIDOC ## hash(half2) ### Description Returns a uint hash code of a half2 vector. ### Method Not applicable (static method). ### Endpoint Not applicable (static method). ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp half2 vec = new half2(1.0f, 2.0f); uint hashValue = Math.hash(vec); ``` ### Response #### Success Response (200) - **uint**: uint hash of the argument. ``` -------------------------------- ### hash(double3x2) Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.math Returns a uint hash code of a double3x2 matrix. ```APIDOC ## hash(double3x2) ### Description Returns a uint hash code of a double3x2 matrix. ### Method Not applicable (static method). ### Endpoint Not applicable (static method). ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp double3x2 matrix = new double3x2(1.0, 2.0, 3.0, 4.0, 5.0, 6.0); uint hashValue = Math.hash(matrix); ``` ### Response #### Success Response (200) - **uint**: uint hash of the argument. ``` -------------------------------- ### hash(double2x2) Source: https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/Packages/com.unity.mathematics%401.3/api/Unity.Mathematics.math Returns a uint hash code of a double2x2 matrix. ```APIDOC ## hash(double2x2) ### Description Returns a uint hash code of a double2x2 matrix. ### Method Not applicable (static method). ### Endpoint Not applicable (static method). ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp double2x2 matrix = new double2x2(1.0, 2.0, 3.0, 4.0); uint hashValue = Math.hash(matrix); ``` ### Response #### Success Response (200) - **uint**: uint hash of the argument. ```