Repository navigation
Open
Labels
enhancementNew feature or request
Description
Plan:
Semantics/docs/strategy-unified-vector-quantities.md
Lines 160 to 166 in ff736ff
| **3. Cross product** (`.Cross()`) - two V3 operands, result is V3: | |
| ``` | |
| V3 × V3 → V3 Displacement3D × Force3D = Torque3D | |
| AngularVelocity3D × Displacement3D = Velocity3D | |
| ``` |
3. Cross product (
.Cross()) - two V3 operands, result is V3:V3 × V3 → V3 Displacement3D × Force3D = Torque3D AngularVelocity3D × Displacement3D = Velocity3D
What exists today
- The doc gives two cross-product examples, and only the first one, Torque, exists. It is declared on
LengthinSemantics.SourceGenerators/Metadata/dimensions.json(L86-L89), next toDisplacement3D × Velocity3D = SpecificAngularMomentum3D. The generator emits both asDisplacement3D.Cross(...). AngularVelocityindimensions.json(around L436-L452) declares"crossProducts": []. The onlyCrossonAngularVelocity3D<T>is the untyped same-typeCross(AngularVelocity3D<T>)(see Same-type Cross() on 3D quantities returns the operand's dimension, so Displacement3D × Displacement3D (m²) types as a length #521).AngularVelocity3D,Displacement3DandVelocity3Dall exist, and the dimensions check out: T⁻¹ · L = L T⁻¹. The angle is dimensionless in the product.
What's missing
You can't write Velocity3D<double> v = omega.Cross(r); for the tangential velocity of a point on a rotating body. Today you have to unwrap to raw vectors and rebuild the quantity, which loses the type safety the library exists for.
Acceptance criteria
AngularVelocitydeclares{ "other": "Length", "result": "Velocity", "forms": [3] }incrossProducts.- The order is ω × r, so the declaration goes on AngularVelocity, the same way r × F lives on Length.
- The reverse order is the negation, and a dimension check can't catch a wrong sign, so it must not be auto-generated as commutative.
- The generated
AngularVelocity3D<T>.Cross(Displacement3D<T>)returnsVelocity3D<T>. - The committed generated output, the C++ projection and the vocabulary are regenerated, and verify-generated passes.
- A test next to the existing
r.Cross(f)test inSemantics.Test/Quantities/VectorQuantityTests.cschecks the sign: ω = (0, 0, 1) rad/s × r = (1, 0, 0) m = (0, 1, 0) m/s. - Overload operands such as
Position3Dfollow whateverPosition3D.Cross(Force3D)andPosition3D.Cross(Velocity3D)don't compile: vector overloads don't forward their base's typed cross products #506 settles.
Dependencies
None blocking. Related:
- Same-type Cross() on 3D quantities returns the operand's dimension, so Displacement3D × Displacement3D (m²) types as a length #521: the return dimension of same-type
Cross Position3D.Cross(Force3D)andPosition3D.Cross(Velocity3D)don't compile: vector overloads don't forward their base's typed cross products #506: overloads don't forward typed cross productsSemantics.QuantitiesREADME vector example doesn't compile:Force3D.Dot(Displacement3D)was removed in 5.0 andForce3D.Cross(Displacement3D)doesn't exist #543: the strategy doc's vector sections are stale
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
matt-edmondson commentedon Nov 9, 2026
Triage
dimensions.json), regenerated output and one sign test.Semantics.SourceGenerators/Metadata/dimensions.json(theAngularVelocitycrossProducts) andSemantics.Test/Quantities/VectorQuantityTests.cs. The cross product is anticommutative, so it must not be generated in both operand orders.Crossreturn dimension),Position3D.Cross(Force3D)andPosition3D.Cross(Velocity3D)don't compile: vector overloads don't forward their base's typed cross products #506 (overload forwarding) andSemantics.QuantitiesREADME vector example doesn't compile:Force3D.Dot(Displacement3D)was removed in 5.0 andForce3D.Cross(Displacement3D)doesn't exist #543 (stale strategy doc).Generated by Claude Code