A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Arab Legion token flies Transjordan's 1948 flag (Refs #756, slice 1) (#1368)
Berie86575ec1b9e
diff --git a/changelog.d/756-arab-legion-flag.md b/changelog.d/756-arab-legion-flag.mdnew file mode 100644index 000000000..11b574677--- /dev/null+++ b/changelog.d/756-arab-legion-flag.md@@ -0,0 +1,3 @@+- The Arab Legion's tokens fly Transjordan's 1948 flag in place of the neutral pennant: black, white and green bands,+ the red triangle at the hoist and the white seven-pointed star, drawn from the Organic Law of 16 April 1928, Art. 3+ (#756). The Arab Liberation Army keeps the pennant.diff --git a/unity/Assets/Scripts/Map/Units/UnitFlags.cs b/unity/Assets/Scripts/Map/Units/UnitFlags.csindex 8ec700ef8..d763b148f 100644--- a/unity/Assets/Scripts/Map/Units/UnitFlags.cs+++ b/unity/Assets/Scripts/Map/Units/UnitFlags.cs@@ -1,4 +1,5 @@#nullable enable+using System;using System.Collections.Generic;using UnityEngine;using P = Statecraft.Game.Map.Units.UnitPalette;@@ -22,8 +23,20 @@ namespace Statecraft.Game.Map.Units/// Israel", https://en.wikipedia.org/wiki/Israeli_Declaration_of_Independence, checked 2026-10-14), so it flies from/// the game's first day. The gazette says only "dark sky-blue" (tkhelet kehe); the cloth's blue/// (<see cref="BlueColour"/>) is a choice, a little brighter than the roundel's so it reads unlit.- /// - Egypt, Jordan, Syria, Iraq, Lebanon: no sourced flag in the repo yet, so none. A side the map draws without one (the- /// Arab Legion and the Arab Liberation Army, issue #665) flies a neutral pennant instead (<see cref="BuildPennant"/>):+ /// - Transjordan (the Arab Legion's tokens; owner, 22 October 2026, #756: each Arab side flies "the sourced 1948 flag ...+ /// Where no source exists, a neutral pennant"): the Organic Law of 16 April 1928, Art. 3, French translation on the+ /// Digithèque MJP (https://mjp.univ-perp.fr/constit/jo1928.htm, read 2026-10-22 through the Wayback Machine; source+ /// research_notes/GDD phase 5/unit-art-sourcing-1948.md, section 1): the length twice the width; three equal bands,+ /// black, white and green from the top; at the hoist a red triangle whose longest side is the flag's width and whose+ /// height is a quarter of its length; at the meeting of the triangle's bisectors a white seven-pointed star that fits a+ /// circle a twenty-fourth of the length across, the axis through one of its points parallel to the staff+ /// (<see cref="BuildTransjordan"/>). The note's open points, kept as the law has them: that the flag was unchanged on+ /// 15 May 1948 rests on one search snippet [S], and a later, longer triangle is reported [C]. The law names the colours+ /// only: their values (<see cref="BlackColour"/>, <see cref="GreenColour"/>, <see cref="RedColour"/>) are a choice, as+ /// are the star's point up (the law fixes the axis, not which end) and the depth of its points.+ /// - Egypt, Syria, Iraq, Lebanon: no figure on the map yet, so no flag drawn (#756 follows the same code once they have+ /// one). A side the map draws without a sourced flag (the Arab Liberation Army, issue #665) flies a neutral pennant+ /// instead (<see cref="BuildPennant"/>):/// Q-ART-1, decided by the owner on 15 October 2026 ("2+3"): "a neutral pennant now, replaced by a sourced emblem when/// one is found" (docs/superpowers/plans/2026-10-15-gdd-phase-5.md, PR 17). Never the ALA's dagger emblem (#226,/// ruling 8).@@ -41,7 +54,10 @@ namespace Statecraft.Game.Map.Unitspublic const float StarOuterCm = 34.5f;const float StripeCm = 5.5f, Layer = 0.02f; // the blue a fiftieth of a figure off the white: enough depth for WebGL at 60 km- static readonly HashSet<string> Sourced = new HashSet<string> { UnitData.Israel };+ /// <summary>The Arab Legion's side (<see cref="UnitFigures.BySide"/>).</summary>+ public const string Jordan = "jordan";++ static readonly HashSet<string> Sourced = new HashSet<string> { UnitData.Israel, Jordan };public static bool Has(string? side) => side != null && Sourced.Contains(side);@@ -71,6 +87,7 @@ namespace Statecraft.Game.Map.Unitspublic static Mesh? Build(string? side){if (!Has(side)) return null;+ if (side == Jordan) return BuildTransjordan();var m = new MiniatureMesh();m.Rod(Vector3.zero, new Vector3(0, PoleHeight, 0), PoleRadius, PoleRadius * 0.8f, P.RifleWood, segments: 8, shade: 0.7f);m.Ellipsoid(Matrix4x4.TRS(new Vector3(0, PoleHeight + 0.02f, 0), Quaternion.identity, Vector3.one * 0.035f), P.RifleWood, 8, 4, shade: 0.9f);@@ -89,28 +106,83 @@ namespace Statecraft.Game.Map.Unitsm.Plate(at, new List<Vector2> { Corner(k, StarOuterCm), Corner(k + 1, StarOuterCm), Corner(k + 1, inner), Corner(k, inner) }, P.RoundelBlue, shade: 0.85f);}}- return Split(m.Build(MeshName(side!)));+ return Split(m.Build(MeshName(side!)), IsraelSlots);+ }++ static readonly int[] IsraelSlots = { P.RoundelWhite, P.RoundelBlue }, TransjordanSlots = { P.PropBlack, P.CamoGreen, P.MarkingRed, P.RoundelWhite };++ /// <summary>Transjordan's flag (the class note), in the law's units: the length 2 along +x from the pole, the width 1,+ /// the cloth's top at <see cref="FlagTop"/>. The bands are cut around the triangle (0,0), (0,1), (1/2,1/2), so the cloth+ /// is one layer; only the star lies on the red, a hair off it on both faces.</summary>+ static Mesh BuildTransjordan()+ {+ var m = new MiniatureMesh();+ m.Rod(Vector3.zero, new Vector3(0, PoleHeight, 0), PoleRadius, PoleRadius * 0.8f, P.RifleWood, segments: 8, shade: 0.7f);+ m.Ellipsoid(Matrix4x4.TRS(new Vector3(0, PoleHeight + 0.02f, 0), Quaternion.identity, Vector3.one * 0.035f), P.RifleWood, 8, 4, shade: 0.9f);+ float s = FlagWidth / 2f;+ Vector2 F(float x, float y) => new Vector2(FlagLeft + x * s, FlagTop - s + y * s);+ const float third = 1f / 3f, twoThirds = 2f / 3f;+ var at = Plane(0f);+ m.Plate(at, new List<Vector2> { F(0, 1), F(2, 1), F(2, twoThirds), F(third, twoThirds) }, P.PropBlack, shade: 0.9f);+ m.Plate(at, new List<Vector2> { F(third, twoThirds), F(2, twoThirds), F(2, 0.5f), F(0.5f, 0.5f) }, P.RoundelWhite, shade: 0.9f);+ m.Plate(at, new List<Vector2> { F(0.5f, 0.5f), F(2, 0.5f), F(2, third), F(third, third) }, P.RoundelWhite, shade: 0.9f);+ m.Plate(at, new List<Vector2> { F(0, 0), F(third, third), F(2, third), F(2, 0) }, P.CamoGreen, shade: 0.9f);+ m.Plate(at, new List<Vector2> { F(0, 0), F(0, 1), F(0.5f, 0.5f) }, P.MarkingRed, shade: 0.9f);+ // The star at the incentre of the triangle (sides 1, sqrt 1/2, sqrt 1/2): (1/(2+2 sqrt 2), 1/2), its inradius from+ // the hoist; its points on a circle of radius 1/24 (a diameter of a twenty-fourth of the length 2), one point up.+ // The inner corners at the regular {7/2} star's depth: the law gives none.+ float cx = 1f / (2f + 2f * Mathf.Sqrt(2f)), outer = 1f / 24f, inner = outer * Mathf.Cos(2f * Mathf.PI / 7f) / Mathf.Cos(Mathf.PI / 7f);+ var star = new List<Vector2> { F(cx, 0.5f) }; // a fan from the centre+ for (int i = 0; i <= 14; i++)+ {+ float a = Mathf.PI / 2f + i * Mathf.PI / 7f, r = i % 2 == 0 ? outer : inner;+ star.Add(F(cx + r * Mathf.Cos(a), 0.5f + r * Mathf.Sin(a)));+ }+ foreach (float z in new[] { Layer, -Layer }) m.Plate(Plane(z), star, P.RoundelWhite, shade: 0.9f);+ return Split(m.Build(MeshName(Jordan)), TransjordanSlots);}/// <summary>The cloth's colours, drawn unlit (the selection ring's shader) so the flag reads white and blue under/// the map's light and grade, as T29's (its white 0.83-0.91 luma). The blue stands for the proclamation's "dark/// sky-blue", which gives no value: a choice.</summary>public static readonly Color WhiteColour = new Color(1f, 1f, 1f), BlueColour = new Color(0.0f, 0.22f, 0.62f);+ /// <summary>Transjordan's black, green and red: the 1928 law names the colours, not their values, so these are a choice+ /// (plain, saturated cloth colours that read unlit).</summary>+ public static readonly Color BlackColour = new Color(0.05f, 0.05f, 0.05f), GreenColour = new Color(0.0f, 0.45f, 0.22f), RedColour = new Color(0.78f, 0.08f, 0.10f);++ /// <summary>The cloth's colours of <paramref name="side"/>'s flag, one per submesh after the pole's, in drawing order+ /// (a later colour lies over an earlier one).</summary>+ public static IReadOnlyList<Color> Colours(string side) =>+ side == Jordan ? new[] { BlackColour, GreenColour, RedColour, WhiteColour } : new[] { WhiteColour, BlueColour };++ /// <summary>The unlit cloth materials for <paramref name="side"/>'s flag, one per <see cref="Colours"/>, each drawn after+ /// the one before (the blue over the white, the star over the red).</summary>+ public static Material[] ClothMaterials(string side, Material ringTemplate, Func<Material, Material> own)+ {+ var colours = Colours(side); var mats = new Material[colours.Count];+ for (int i = 0; i < mats.Length; i++)+ {+ mats[i] = own(new Material(ringTemplate) { name = $"UnitFlag ({side} {i})", color = colours[i] });+ if (i > 0) mats[i].renderQueue = mats[0].renderQueue + i;+ }+ return mats;+ }- /// <summary>Puts the pole, the white and the blue in submeshes 0, 1 and 2 (the palette, white and blue materials).</summary>- static Mesh Split(Mesh mesh)+ /// <summary>Puts the pole in submesh 0 and the cloth of palette slot <paramref name="slots"/>[k] in submesh k + 1 (the+ /// palette, then the cloth materials).</summary>+ static Mesh Split(Mesh mesh, int[] slots){var uv = mesh.uv; var t = mesh.triangles;- var parts = new[] { new List<int>(), new List<int>(), new List<int>() };- float white = P.U(P.RoundelWhite), blue = P.U(P.RoundelBlue);+ var parts = new List<int>[slots.Length + 1];+ for (int k = 0; k < parts.Length; k++) parts[k] = new List<int>();for (int i = 0; i < t.Length; i += 3){float u = uv[t[i]].x;- int k = Mathf.Abs(u - white) < 1e-4f ? 1 : Mathf.Abs(u - blue) < 1e-4f ? 2 : 0;+ int k = 1 + Array.FindIndex(slots, slot => Mathf.Abs(u - P.U(slot)) < 1e-4f);parts[k].Add(t[i]); parts[k].Add(t[i + 1]); parts[k].Add(t[i + 2]);}- mesh.subMeshCount = 3;- for (int k = 0; k < 3; k++) mesh.SetTriangles(parts[k], k);+ mesh.subMeshCount = parts.Length;+ for (int k = 0; k < parts.Length; k++) mesh.SetTriangles(parts[k], k);return mesh;}diff --git a/unity/Assets/Scripts/Map/Units/UnitLayer.cs b/unity/Assets/Scripts/Map/Units/UnitLayer.csindex d54d91016..72f563511 100644--- a/unity/Assets/Scripts/Map/Units/UnitLayer.cs+++ b/unity/Assets/Scripts/Map/Units/UnitLayer.cs@@ -31,7 +31,8 @@ namespace Statecraft.Game.Map.UnitsUnitGround ground = null!;IReadOnlyDictionary<UnitAnchor, AnchorSpot> spots = new Dictionary<UnitAnchor, AnchorSpot>();MapRuntimeAssets assets = null!;- Material paint = null!, ringTemplate = null!, badgePlate = null!, badgeGlyph = null!, rim = null!, flagWhite = null!, flagBlue = null!;+ Material paint = null!, ringTemplate = null!, badgePlate = null!, badgeGlyph = null!, rim = null!;+ readonly Dictionary<string, Material[]> flagCloth = new Dictionary<string, Material[]>(); // per side, made on first usereadonly Dictionary<string, Mesh> meshes = new Dictionary<string, Mesh>();/// <summary>The meshes built for the tokens drawn now (each base's draped top, lip and ring follow its own ground):/// destroyed when the tokens are rebuilt and with the layer, so no roster change leaks them (review of #559, M1).</summary>@@ -141,9 +142,6 @@ namespace Statecraft.Game.Map.Unitslayer.badgePlate = layer.assets.Own(new Material(ringTemplate) { name = "UnitBadge (plate)", color = UnitBadge.PlateColour });layer.badgeGlyph = layer.assets.Own(new Material(ringTemplate) { name = "UnitBadge (glyph)", color = UnitBadge.GlyphColour });layer.rim = layer.assets.Own(new Material(ringTemplate) { name = "UnitPlinthRim", color = UnitPlinth.RimColour });- layer.flagWhite = layer.assets.Own(new Material(ringTemplate) { name = "UnitFlag (white)", color = UnitFlags.WhiteColour });- layer.flagBlue = layer.assets.Own(new Material(ringTemplate) { name = "UnitFlag (blue)", color = UnitFlags.BlueColour });- layer.flagBlue.renderQueue = layer.flagWhite.renderQueue + 1; // the blue over the whitelayer.tokensRoot = new GameObject("Tokens").transform;layer.tokensRoot.SetParent(root.transform, false);// The kit trees under the figures are left out while the layer shows (issue #249), and come back with the layer@@ -381,6 +379,13 @@ namespace Statecraft.Game.Map.Unitsreturn mesh;}+ /// <summary>A side's flag cloth materials, made once per side and shared by its tokens.</summary>+ Material[] FlagCloth(string side)+ {+ if (!flagCloth.TryGetValue(side, out var mats)) flagCloth[side] = mats = UnitFlags.ClothMaterials(side, ringTemplate, assets.Own);+ return mats;+ }+/// <summary>Takes a mesh built for one token: freed with the tokens (<see cref="FreeTokenMeshes"/>).</summary>Mesh TokenMesh(Mesh m) { tokenMeshes.Add(UnitPlinth.Upload(m)); return m; }@@ -428,7 +433,7 @@ namespace Statecraft.Game.Map.Units// rim, under the side's flag (refs #197). The base fits the full trio, whatever the call-up.float k = UnitShowcase.DrawSpread * hex * Scale(p.Spot);plinth = UnitPlinth.Radius(UnitPlinth.TrioWidth(UnitShowcase.FigureOffsets(3), k));- foot.y = UnitPlinth.Build(map, go.transform, centre, plinth, t.Unit.Side, TokenMesh, MeshFor, paint, rim, flagWhite, flagBlue);+ foot.y = UnitPlinth.Build(map, go.transform, centre, plinth, t.Unit.Side, TokenMesh, MeshFor, paint, rim, FlagCloth);treeHoles.Add((new Vector2(centre.x, centre.z), plinth * UnitPlinth.RimOuter));var offsets = UnitShowcase.FigureOffsets(t.Figures);float highest = foot.y; // the badge clears the highest figure (on a slope the uphill one stands higher)diff --git a/unity/Assets/Scripts/Map/Units/UnitPlinth.cs b/unity/Assets/Scripts/Map/Units/UnitPlinth.csindex a9c2c40e9..13a0479c8 100644--- a/unity/Assets/Scripts/Map/Units/UnitPlinth.cs+++ b/unity/Assets/Scripts/Map/Units/UnitPlinth.cs@@ -1,6 +1,7 @@#nullable enableusing System;using System.Collections.Generic;+using System.Linq;using UnityEngine;namespace Statecraft.Game.Map.Units@@ -250,9 +251,10 @@ namespace Statecraft.Game.Map.Units/// <paramref name="centre"/> under <paramref name="token"/>, and <paramref name="side"/>'s flag when it has one (the neutral/// pennant when the map draws the side without one, <see cref="UnitFlags.HasPennant"/>)./// <paramref name="own"/> takes ownership of each per-token mesh; <paramref name="shared"/> returns the shared flag- /// mesh for a key. Returns the base's top at its centre.</summary>+ /// mesh for a key; <paramref name="flagCloth"/> the side's cloth materials (<see cref="UnitFlags.ClothMaterials"/>).+ /// Returns the base's top at its centre.</summary>public static float Build(MapScene map, Transform token, Vector3 centre, float radius, string side, Func<Mesh, Mesh> own,- Func<string, Func<Mesh>, Mesh> shared, Material paint, Material rim, Material flagWhite, Material flagBlue)+ Func<string, Func<Mesh>, Mesh> shared, Material paint, Material rim, Func<string, Material[]> flagCloth){var ground = HeightAt(map); var c = new Vector2(centre.x, centre.z);var at = new Vector3(centre.x, 0f, centre.z); var scale = new Vector3(radius, 1f, radius);@@ -274,7 +276,7 @@ namespace Statecraft.Game.Map.Units? UnitShowcase.Piece(token, FlagName, shared("unit-pennant", UnitFlags.BuildPennant), paint, foot, Quaternion.identity, UnitBadge.FigureHeightM * UnitShowcase.FigureScale): UnitShowcase.Piece(token, FlagName, shared("unit-flag-" + side, () => UnitFlags.Build(side)!), paint, foot, Quaternion.identity,UnitBadge.FigureHeightM * UnitShowcase.FigureScale);- if (!pennant) flag.GetComponent<MeshRenderer>().sharedMaterials = new[] { paint, flagWhite, flagBlue };+ if (!pennant) flag.GetComponent<MeshRenderer>().sharedMaterials = new[] { paint }.Concat(flagCloth(side)).ToArray();flag.AddComponent<UnitFlagFacing>(); // owner ruling, 2026-10-15: the cloth turns about the pole to face the cameravar cam = Camera.main; if (cam != null) UnitFlagFacing.Face(flag.transform, cam.transform.position);}diff --git a/unity/Assets/Scripts/Map/Units/UnitShowcase.cs b/unity/Assets/Scripts/Map/Units/UnitShowcase.csindex 9a49b963b..c4aea9697 100644--- a/unity/Assets/Scripts/Map/Units/UnitShowcase.cs+++ b/unity/Assets/Scripts/Map/Units/UnitShowcase.cs@@ -141,10 +141,8 @@ namespace Statecraft.Game.Map.Unitsvar offsets = FigureOffsets(looks.Length);float plinth = UnitPlinth.Radius(UnitPlinth.TrioWidth(offsets, DrawSpread * hex));var rim = assets.Own(new Material(ringTemplate) { name = "UnitPlinthRim", color = UnitPlinth.RimColour });- var flagWhite = assets.Own(new Material(ringTemplate) { name = "UnitFlag (white)", color = UnitFlags.WhiteColour });- var flagBlue = assets.Own(new Material(ringTemplate) { name = "UnitFlag (blue)", color = UnitFlags.BlueColour });- flagBlue.renderQueue = flagWhite.renderQueue + 1; // the blue over the white- UnitPlinth.Build(map, root.transform, centre, plinth, UnitData.Israel, m => UnitPlinth.Upload(assets.Own(m)), (_, build) => Built(build()), paint, rim, flagWhite, flagBlue);+ UnitPlinth.Build(map, root.transform, centre, plinth, UnitData.Israel, m => UnitPlinth.Upload(assets.Own(m)), (_, build) => Built(build()), paint, rim,+ side => UnitFlags.ClothMaterials(side, ringTemplate, assets.Own));var holes = new List<(Vector2 centre, float radius)> { (new Vector2(centre.x, centre.z), plinth * UnitPlinth.RimOuter) };for (int i = 0; i < looks.Length; i++){diff --git a/unity/Assets/Tests/EditMode/UnitFiguresTests.cs b/unity/Assets/Tests/EditMode/UnitFiguresTests.csindex 9d174dff9..05f4f6810 100644--- a/unity/Assets/Tests/EditMode/UnitFiguresTests.cs+++ b/unity/Assets/Tests/EditMode/UnitFiguresTests.cs@@ -416,7 +416,13 @@ public class UnitFiguresTests}var flag = go.Find(UnitPlinth.FlagName);Assert.IsNotNull(flag, "a marker on the pole");- Assert.AreEqual(UnitFlags.PennantMeshName, flag.GetComponent<MeshFilter>().sharedMesh.name, "the neutral pennant (Q-ART-1), not a flag");+ Assert.AreEqual(UnitFlags.MeshName(UnitFlags.Jordan), flag.GetComponent<MeshFilter>().sharedMesh.name, "Transjordan's sourced 1948 flag (#756), not the pennant");+ var cloth = flag.GetComponent<MeshRenderer>().sharedMaterials;+ var want = UnitFlags.Colours(UnitFlags.Jordan);+ Assert.AreEqual(1 + want.Count, cloth.Length, "the pole in the palette, then each cloth colour");+ for (int i = 0; i < want.Count; i++) // a material's colour comes back through a float round trip+ Assert.Less(((Vector4)(cloth[i + 1].color - want[i])).magnitude, 1e-3f, $"cloth colour {i}");+ Assert.AreSame(Resources.Load<Material>(UnitMaterials.RingResource).shader, cloth[1].shader, "the cloth unlit");// On the force's own ground (#226, ruling 9): the spot's hex is not Israeli-held on the window's first day.var control = Control1948.Parse(File.ReadAllText(Path.Combine(Paths.Content, "map", Control1948.FileName)));foreach (var u in units.Where(u => u.Side != UnitData.Israel && UnitRoster.OnMap(u)))diff --git a/unity/Assets/Tests/EditMode/UnitPlinthTests.cs b/unity/Assets/Tests/EditMode/UnitPlinthTests.csindex 6d32119c8..769089f06 100644--- a/unity/Assets/Tests/EditMode/UnitPlinthTests.cs+++ b/unity/Assets/Tests/EditMode/UnitPlinthTests.cs@@ -124,7 +124,7 @@ public class UnitPlinthTests/// <summary>Every row of the unit file names its side, and every formation the map draws is Israel's or a force with a/// Collection figure (the other Arab forces' rows are data only; owner, 17 October 2026, #740; issue #665); only Israel- /// has a flag (built from the 1948 specification), so no flag is invented: a drawn force with none flies the neutral+ /// and the Arab Legion have a flag (built from the 1948 texts), so no flag is invented: a drawn force with none flies the neutral/// pennant (Q-ART-1, owner, 15 October 2026), in neither side's colours and not white, and no other side flies anything.</summary>[Test]public void TheFlagIsTheSidesAndOnlyASourcedFlagIsDrawn()@@ -134,7 +134,9 @@ public class UnitPlinthTests"every formation the map draws is Israel's or has its own figure");Assert.IsTrue(UnitFlags.Has(UnitData.Israel));Assert.IsFalse(UnitFlags.HasPennant(UnitData.Israel));- foreach (var side in UnitData.Sides.Where(s => s != UnitData.Israel))+ Assert.IsTrue(UnitFlags.Has(UnitFlags.Jordan), "the Arab Legion's sourced 1948 flag (owner, 22 October 2026, #756)");+ Assert.IsFalse(UnitFlags.HasPennant(UnitFlags.Jordan));+ foreach (var side in UnitData.Sides.Where(s => s != UnitData.Israel && s != UnitFlags.Jordan)){Assert.IsFalse(UnitFlags.Has(side), $"{side}: no sourced, licensed flag in the repo, so none");Assert.IsNull(UnitFlags.Build(side), side);@@ -211,6 +213,63 @@ public class UnitPlinthTestsUnityEngine.Object.DestroyImmediate(m);}+ /// <summary>The Arab Legion's flag, Transjordan's as its Organic Law of 16 April 1928, Art. 3 gives it (the sourcing+ /// note's section 1; owner, 22 October 2026, #756): twice as long as wide, three equal bands, black, white and green from+ /// the top; at the hoist a red triangle whose longest side is the flag's width and whose height is a quarter of its+ /// length; in it a white seven-pointed star a twenty-fourth of the length across, centred where the triangle's+ /// bisectors meet, the axis through one point parallel to the pole. Measured by area, in the law's units (length 2).</summary>+ [Test]+ public void TheArabLegionFliesTransjordansFlagAsThe1928LawGivesIt()+ {+ var m = UnitFlags.Build(UnitFlags.Jordan);+ Assert.IsNotNull(m);+ Assert.AreEqual(UnitFlags.MeshName(UnitFlags.Jordan), m!.name);+ var colours = UnitFlags.Colours(UnitFlags.Jordan);+ Assert.AreEqual(1 + colours.Count, m.subMeshCount, "the pole, then one submesh per colour of the cloth");+ int Sub(Color c) => 1 + colours.ToList().IndexOf(c);+ float k = 2f / UnitFlags.FlagWidth, bottom = UnitFlags.FlagTop - UnitFlags.FlagWidth / 2f;+ var v = m.vertices.Select(p => new Vector3((p.x - UnitFlags.FlagLeft) * k, (p.y - bottom) * k, p.z)).ToArray();+ // One face's area of a colour: every plate is two-sided, so half the sum; the star (off the cloth's plane) separately.+ float Area(int sub, bool star)+ {+ var t = m.GetTriangles(sub); float a = 0f;+ for (int i = 0; i < t.Length; i += 3)+ {+ if ((Mathf.Abs(v[t[i]].z) > 1e-4f) != star || star && v[t[i]].z < 0f) continue;+ Vector2 p = v[t[i]], q = v[t[i + 1]], r = v[t[i + 2]];+ a += Mathf.Abs((q.x - p.x) * (r.y - p.y) - (r.x - p.x) * (q.y - p.y)) / 2f;+ }+ return a / 2f;+ }+ int black = Sub(UnitFlags.BlackColour), white = Sub(UnitFlags.WhiteColour), green = Sub(UnitFlags.GreenColour), red = Sub(UnitFlags.RedColour);+ Assert.That(new[] { black, white, green, red }, Is.All.GreaterThan(0), "black, white, green and red cloth");+ // The triangle (0,0), (0,1), (1/2,1/2) cuts 1/18 off the black and the green band and 1/4 - 2/18 off the white.+ Assert.AreEqual(0.25f, Area(red, false), 1e-4f, "the red triangle: the width at the hoist, a quarter of the length deep");+ Assert.AreEqual(2f / 3f - 1f / 18f, Area(black, false), 1e-4f, "the black band, the top third");+ Assert.AreEqual(2f / 3f - 1f / 18f, Area(green, false), 1e-4f, "the green band, the bottom third");+ Assert.AreEqual(2f / 3f - (0.25f - 2f / 18f), Area(white, false), 1e-4f, "the white band, the middle third");+ Assert.That(m.GetTriangles(black).Select(i => v[i].y), Is.All.GreaterThanOrEqualTo(2f / 3f - 1e-4f), "black on top");+ Assert.That(m.GetTriangles(green).Select(i => v[i].y), Is.All.LessThanOrEqualTo(1f / 3f + 1e-4f), "green below");+ Assert.That(m.GetTriangles(red).Select(i => v[i].x), Is.All.LessThanOrEqualTo(0.5f + 1e-4f), "red at the hoist");+ var cloth = Enumerable.Range(1, colours.Count).SelectMany(m.GetTriangles).Select(i => v[i]).ToList();+ Assert.AreEqual(2f, cloth.Max(p => p.x), 1e-4f); Assert.AreEqual(1f, cloth.Max(p => p.y), 1e-4f, "2:1");+ Assert.AreEqual(0f, cloth.Min(p => p.x), 1e-4f); Assert.AreEqual(0f, cloth.Min(p => p.y), 1e-4f);+ // The star: white, over the red, centred on the incentre (the side-weighted mean of the corners, each corner weighted+ // by the side opposite it), its points on a circle 1/12 across.+ Vector2 A = new Vector2(0f, 0f), B = new Vector2(0f, 1f), Cc = new Vector2(0.5f, 0.5f);+ float sa = (B - Cc).magnitude, sb = (Cc - A).magnitude, sc = (A - B).magnitude;+ var centre = (sa * A + sb * B + sc * Cc) / (sa + sb + sc);+ Assert.AreEqual(centre.x, (1f - centre.x - centre.y) / Mathf.Sqrt(2f), 1e-4f, "as far from the hoist as from the upper edge x + y = 1");+ var star = m.GetTriangles(white).Select(i => v[i]).Where(p => Mathf.Abs(p.z) > 1e-4f).Select(p => (Vector2)p - centre).ToList();+ Assert.IsNotEmpty(star, "a white star, off the cloth's plane on both faces");+ Assert.That(star.Max(q => q.magnitude), Is.EqualTo(1f / 24f).Within(1e-4f), "a twenty-fourth of the length across");+ var points = star.Where(q => Mathf.Abs(q.magnitude - 1f / 24f) < 1e-4f).Select(q => Mathf.Round(Mathf.Repeat(Mathf.Atan2(q.y, q.x) * Mathf.Rad2Deg, 360f) * 10f) / 10f).Distinct().ToList();+ Assert.AreEqual(7, points.Count, "seven points");+ Assert.IsTrue(points.Any(a => Mathf.Abs(Mathf.DeltaAngle(a, 90f)) < 0.05f), "one point's axis parallel to the pole");+ Assert.That(Area(white, true), Is.GreaterThan(0f).And.LessThan(Mathf.PI / 576f), "a star inside its circle");+ UnityEngine.Object.DestroyImmediate(m);+ }+// ---- The scale ------------------------------------------------------------------------------------------------/// <summary>T29's figures stand about 1.8 times a house; T54 measured main's at about 2.5 at close30 against the White