< Summary - ReFlex - Library

Information
Class: ReFlex.Core.Common.Components.Vector3
Assembly: ReFlex.Core.Common
File(s): D:\a\reflex\reflex\library\src\Core\Common\Components\Vector3.cs
Line coverage
45%
Covered lines: 11
Uncovered lines: 13
Coverable lines: 24
Total lines: 145
Line coverage: 45.8%
Branch coverage
0%
Covered branches: 0
Total branches: 10
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_X()100%11100%
get_Y()100%11100%
get_Z()100%11100%
get_IsValid()100%11100%
get_IsFiltered()100%11100%
.ctor()100%210%
.ctor(...)100%11100%
.ctor(...)100%210%
Set(...)100%210%
Copy()100%210%
get_Length()100%210%
get_NormalizedCopy()0%620%
Set(...)100%11100%
Equals(...)0%4260%
ToString()0%620%

File(s)

D:\a\reflex\reflex\library\src\Core\Common\Components\Vector3.cs

#LineLine coverage
 1using ReFlex.Core.Common.Interfaces;
 2
 3namespace ReFlex.Core.Common.Components
 4{
 5    /// <inheritdoc />
 6    /// <summary>
 7    /// A threedimensional vector.
 8    /// </summary>
 9    /// <seealso cref="IBase3" />
 10    public class Vector3 : IBase3
 11    {
 12        /// <inheritdoc />
 13        /// <summary>
 14        /// Gets or sets the x value.
 15        /// </summary>
 16        /// <value>
 17        /// The x value.
 18        /// </value>
 819        public float X { get; set; }
 20
 21        /// <inheritdoc />
 22        /// <summary>
 23        /// Gets or sets the y value.
 24        /// </summary>
 25        /// <value>
 26        /// The y value.
 27        /// </value>
 828        public float Y { get; set; }
 29
 30        /// <inheritdoc />
 31        /// <summary>
 32        /// Gets or sets the z value.
 33        /// </summary>
 34        /// <value>
 35        /// The z value.
 36        /// </value>
 837        public float Z { get; set; }
 38
 39        /// <summary>
 40        /// Returns true if the vector is valid.
 41        /// </summary>
 42        /// <value>
 43        ///   <c>true</c> if this vector is valid; otherwise, <c>false</c>.
 44        /// </value>
 45        /// <inheritdoc />
 446        public bool IsValid { get; set; } = true;
 47
 48        /// <summary>
 49        /// Returns true if this vector is filtered.
 50        /// </summary>
 51        /// <value>
 52        ///   <c>true</c> if this vector is filtered; otherwise, <c>false</c>.
 53        /// </value>
 54        /// <inheritdoc />
 455        public bool IsFiltered { get; set; } = true;
 56
 57
 58        /// <summary>
 59        /// Initializes a new instance of the <see cref="Vector3"/> class.
 60        /// </summary>
 061        public Vector3() => Set(0, 0, 0);
 62
 63        /// <summary>
 64        /// Initializes a new instance of the <see cref="Vector3"/> class.
 65        /// </summary>
 66        /// <param name="x">The x.</param>
 67        /// <param name="y">The y.</param>
 68        /// <param name="z">The z.</param>
 869        public Vector3(float x, float y, float z) => Set(x, y, z);
 70
 71        /// <summary>
 72        /// Initializes a new instance of the <see cref="Vector3"/> class.
 73        /// </summary>
 74        /// <param name="base3">The base3.</param>
 075        public Vector3(IBase3 base3) => Set(base3);
 76
 77        /// <inheritdoc />
 78        /// <summary>
 79        /// Copies the values from the input to [this] instance.
 80        /// </summary>
 81        /// <param name="base3">The base3 input.</param>
 082        public void Set(IBase3 base3) => Set(base3.X, base3.Y, base3.Z);
 83
 84        /// <inheritdoc />
 85        /// <summary>
 86        /// Copies this instance.
 87        /// </summary>
 88        /// <returns></returns>
 089        public IBase3 Copy() => new Vector3(this);
 90
 91        /// <summary>
 92        /// Gets the length.
 93        /// </summary>
 94        /// <value>
 95        /// The length.
 96        /// </value>
 097        public float Length => (float)System.Math.Sqrt(X * X + Y * Y + Z * Z);
 98
 99        /// <summary>
 100        /// Gets the normalized copy.
 101        /// </summary>
 102        /// <value>
 103        /// The normalized copy.
 104        /// </value>
 0105        public Vector3 NormalizedCopy => Length > 0 ? new Vector3(X / Length, Y / Length, Z / Length) : new Vector3();
 106
 107        /// <inheritdoc />
 108        /// <summary>
 109        /// Sets the x, y and z value.
 110        /// </summary>
 111        /// <param name="x">The x value.</param>
 112        /// <param name="y">The y value.</param>
 113        /// <param name="z">The z value.</param>
 114        public void Set(float x, float y, float z)
 4115        {
 4116            X = x;
 4117            Y = y;
 4118            Z = z;
 4119        }
 120
 121        /// <inheritdoc />
 122        /// <summary>
 123        /// Compares [this] instance with the input.
 124        /// </summary>
 125        /// <param name="base3">The base3 to compare with.</param>
 126        /// <returns>
 127        /// <c>true</c> if the values of the input and [this] instance are equal.
 128        /// </returns>
 129        public bool Equals(IBase3 base3)
 0130        {
 0131            return base3 != null &&
 0132                    Equals(X, base3.X) &&
 0133                    Equals(Y, base3.Y) &&
 0134                    Equals(Z, base3.Z);
 0135        }
 136
 137        /// <summary>
 138        /// Returns a <see cref="string" /> that represents [this] instance.
 139        /// </summary>
 140        /// <returns>
 141        /// A <see cref="string" /> that represents [this] instance.
 142        /// </returns>
 0143        public override string ToString() => IsValid ? $"X: {X}; Y: {Y}; Z: {Z}" : "invalid";
 144    }
 145}