@@ -99,45 +99,53 @@ Every quantity is a vector. Direction-space dimensionality is part of the type:
9999``` csharp
100100using ktsu .Semantics .Quantities ;
101101
102- // V0 magnitudes
102+ // V0 magnitudes — From{Unit} factories use the plural form (#49)
103103var speed = Speed <double >.FromMetersPerSecond (15 . 0 );
104- var mass = Mass <double >.FromKilogram (10 . 0 );
105- var distance = Distance <double >.FromMeter (5 . 0 );
104+ var mass = Mass <double >.FromKilograms (10 . 0 );
105+ var distance = Distance <double >.FromMeters (5 . 0 );
106106
107- // V3 directional
108- var force3d = Force3D <double >. FromNewton ( 0 . 0 , 0 . 0 , - 9 . 8 ) ;
109- var disp3d = Displacement3D <double >. FromMeter ( 3 . 0 , 4 . 0 , 0 . 0 ) ;
107+ // V3 directional — object-initializer syntax (X/Y/Z components)
108+ var force3d = new Force3D <double > { X = 0 . 0 , Y = 0 . 0 , Z = - 9 . 8 } ;
109+ var disp3d = new Displacement3D <double > { X = 3 . 0 , Y = 4 . 0 , Z = 0 . 0 } ;
110110
111111// Operators flow from dimensions.json
112- var work = ForceMagnitude <double >.FromNewton (10 . 0 ) * distance ; // F·d = Energy
113- var power = work / Duration <double >.FromSecond (2 . 0 ); // W/t = Power
112+ var work = ForceMagnitude <double >.FromNewtons (10 . 0 ) * distance ; // F·d = Energy
113+ var power = work / Duration <double >.FromSeconds (2 . 0 ); // W/t = Power
114114
115115// Vector ops
116116var workDot = force3d .Dot (disp3d ); // Energy
117117var torque = force3d .Cross (disp3d ); // Torque3D
118- var mag = disp3d .Magnitude (); // Distance (always >= 0)
118+ var mag = disp3d .Magnitude (); // Length (always >= 0)
119+
120+ // Construction-time invariants (#50, #51)
121+ // Speed.FromMetersPerSecond(-1.0) // ArgumentException — V0 must be non-negative
122+ // Wavelength<double>.FromMeters(0.0) // ArgumentException — strict-positive overload
119123
120124// Type safety
121- // var nope = force3d + speed; // ❌ compiler error
125+ // var nope = force3d + speed; // ❌ compiler error
122126```
123127
124128Semantic overloads (e.g. ` Weight ` over ` ForceMagnitude ` , ` Diameter ` ↔ ` Radius ` ):
125129
126130``` csharp
127- var raw = ForceMagnitude <double >.FromNewton (686 . 0 );
131+ var raw = ForceMagnitude <double >.FromNewtons (686 . 0 );
128132var weight = Weight <double >.From (raw ); // explicit narrow
129133ForceMagnitude < double > back = weight ; // implicit widen
130134
131- var radius = Radius <double >.FromMeter (2 . 0 );
135+ var radius = Radius <double >.FromMeters (2 . 0 );
132136var diameter = radius .ToDiameter (); // 4 m via metadata-defined relationship
133137```
134138
135- Physical constants:
139+ Physical constants are exposed in two shapes :
136140
137141``` csharp
138- var c = PhysicalConstants .Generic .SpeedOfLight <double >(); // 299_792_458 m/s
139- var R = PhysicalConstants .Generic .GasConstant <decimal >();
140- var ftM = PhysicalConstants .Conversion .FeetToMeters <double >(); // 0.3048
142+ // Domain-grouped, exact PreciseNumber values:
143+ PhysicalConstants .Fundamental .SpeedOfLight ; // 299_792_458 m/s as PreciseNumber
144+ PhysicalConstants .Chemistry .GasConstant ; // 8.31446... J/(mol·K)
145+
146+ // Generic accessors — materialise into any T : INumber<T>:
147+ var c = PhysicalConstants .Generic .SpeedOfLight <double >();
148+ var R = PhysicalConstants .Generic .GasConstant <decimal >();
141149```
142150
143151The unified vector model and its rationale: [ ` docs/strategy-unified-vector-quantities.md ` ] ( docs/strategy-unified-vector-quantities.md ) .
@@ -161,12 +169,18 @@ public class UserService(ISemanticStringFactory<EmailAddress> emails)
161169## Architecture
162170
163171The physics system is ** metadata-driven** . The single source of truth is
164- ` Semantics.SourceGenerators/Metadata/dimensions.json ` , with a Roslyn incremental generator emitting :
172+ ` Semantics.SourceGenerators/Metadata/dimensions.json ` ( with ` units.json ` , ` magnitudes.json ` , ` conversions.json ` , and ` domains.json ` alongside it), and a Roslyn incremental generator emits :
165173
166174- One record per quantity (Vector0/1/2/3/4 base + semantic overloads).
167- - ` From{Unit} ` factories.
168- - Cross-dimensional ` * ` , ` / ` , ` Dot ` , ` Cross ` operators.
169- - ` PhysicalConstants.Generic.X<T>() ` and ` PhysicalConstants.Conversion.X<T>() ` .
175+ - A ` From{Unit} ` factory per declared unit, with built-in unit conversion to the SI base unit and a ` Vector0Guards ` enforce-non-negative (or strict-positive) check on V0 types.
176+ - Cross-dimensional ` * ` , ` / ` , ` Dot ` , ` Cross ` operators driven by ` integrals ` / ` derivatives ` / ` dotProducts ` / ` crossProducts ` declarations.
177+ - ` PhysicalConstants ` with both domain-grouped ` PreciseNumber ` fields and generic ` T.CreateChecked ` -backed accessors.
178+
179+ Generator diagnostics catch metadata problems at build time:
180+
181+ - ** SEM001** — relationship references an unknown dimension name.
182+ - ** SEM002** — schema-level metadata issue (missing fields, duplicate type names, etc).
183+ - ** SEM003** — relationship's ` forms ` list references a vector form not declared on a participating dimension.
170184
171185Generated output is committed to ` Semantics.Quantities/Generated/ ` so the project compiles without first running the generator.
172186
0 commit comments