{"record":{"id":"873536ed88869763","repo":"stride3d/stride","slug":"there-must-be-four-and-only-four-input-values-for-plane","errorCode":null,"errorMessage":"There must be four and only four input values for Plane.","messagePattern":"There must be four and only four input values for Plane\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Mathematics/Plane.cs","lineNumber":135,"sourceCode":"\n        Normal.X = yz * invPyth;\n        Normal.Y = xz * invPyth;\n        Normal.Z = xy * invPyth;\n        D = -((Normal.X * point1.X) + (Normal.Y * point1.Y) + (Normal.Z * point1.Z));\n    }\n\n    /// <summary>\n    /// Initializes a new instance of the <see cref=\"Stride.Core.Mathematics.Plane\"/> struct.\n    /// </summary>\n    /// <param name=\"values\">The values to assign to the A, B, C, and D components of the plane. This must be an array with four elements.</param>\n    /// <exception cref=\"ArgumentNullException\">Thrown when <paramref name=\"values\"/> is <c>null</c>.</exception>\n    /// <exception cref=\"ArgumentOutOfRangeException\">Thrown when <paramref name=\"values\"/> contains more or less than four elements.</exception>\n    public Plane(float[] values)\n    {\n        if (values == null)\n            throw new ArgumentNullException(nameof(values));\n        if (values.Length != 4)\n            throw new ArgumentOutOfRangeException(nameof(values), \"There must be four and only four input values for Plane.\");\n\n        Normal.X = values[0];\n        Normal.Y = values[1];\n        Normal.Z = values[2];\n        D = values[3];\n    }\n\n    /// <summary>\n    /// Gets or sets the component at the specified index.\n    /// </summary>\n    /// <value>The value of the A, B, C, or D component, depending on the index.</value>\n    /// <param name=\"index\">The index of the component to access. Use 0 for the A component, 1 for the B component, 2 for the C component, and 3 for the D component.</param>\n    /// <returns>The value of the component at the specified index.</returns>\n    /// <exception cref=\"System.ArgumentOutOfRangeException\">Thrown when the <paramref name=\"index\"/> is out of the range [0, 3].</exception>\n    public float this[int index]\n    {\n        get\n        {","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Mathematics/Plane.cs#L117-L153","documentation":"Plane's float[] constructor requires the array to hold exactly 4 elements: Normal.X, Normal.Y, Normal.Z and D. The library throws ArgumentOutOfRangeException when the array length differs from 4, because a plane in 3D cannot be described by any other number of coefficients. This fail-fast check prevents silent misinterpretation of the input array.","triggerScenarios":"Calling new Plane(float[] values) with an array whose Length is not exactly 4, e.g. passing only the 3 normal components, or passing an extra element.","commonSituations":"Deserializing plane data from config or files where the array was truncated or extended; converting from another library's plane representation that uses 3 or 5 values; off-by-one slicing of a larger float buffer.","solutions":["Ensure the array passed to the Plane(float[]) constructor contains exactly 4 floats (Nx, Ny, Nz, D)","Check values.Length == 4 before constructing, or resize/slice the array","Verify the data source (file/config/network) actually provides 4 coefficients per plane"],"exampleFix":"// before\nvar plane = new Plane(normalComponents); // float[3]\n// after\nvar values = new float[] { n.X, n.Y, n.Z, d };\nif (values.Length == 4) { var plane = new Plane(values); }","handlingStrategy":"validation","validationCode":"if (values == null || values.Length != 4) throw new ArgumentException(\"Plane requires exactly 4 floats: Nx, Ny, Nz, D\");\nvar plane = new Plane(values);","typeGuard":"bool IsValidPlaneArray(float[] v) => v != null && v.Length == 4;","tryCatchPattern":"try { var plane = new Plane(values); }\ncatch (ArgumentOutOfRangeException ex) { /* ex.ParamName == \"values\"; handle bad array length */ }","preventionTips":["Always build plane arrays from explicit (Nx, Ny, Nz, D) sources","Assert array length 4 in deserialization code before constructing","Prefer the component constructor over the array constructor"],"tags":["mathematics","argument-out-of-range","plane"],"backgroundTag":"argument-out-of-range","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}