Skip to content

Position3D.Cross(Force3D) and Position3D.Cross(Velocity3D) don't compile: vector overloads don't forward their base's typed cross products #506

Open

Description

@matt-edmondson

What's wrong

#456 made semantic overloads forward their base type's relationship operators, through ForwardedOperators in QuantitiesGenerator.cs. It did not forward the typed Cross and Dot methods. Those are emitted only for base vector types, from emission.ProductsByOwner (around QuantitiesGenerator.cs:1219-1241), and EmitVectorOverloadType never emits them.

They are instance methods on a readonly record struct. Neither inheritance nor implicit widening can reach them through the receiver.

Position3D is an overload of Displacement3D ("Location in 3D space relative to an origin"), so it is the natural r. Yet both cross products declared on Length are missing from it:

  • cross(Displacement3D, Force3D) -> Torque3D
  • cross(Displacement3D, Velocity3D) -> SpecificAngularMomentum3D

The generated Position3D.g.cs has only Dot(Position3D) and Cross(Position3D). Displacement3D.g.cs:209 has Torque3D<T> Cross(Force3D<T> other).

Reproduction (net10.0, at be8aa23)

Position3D<double> r = Position3D<double>.FromMeter(0.5, 0, 0);
Force3D<double> f = Force3D<double>.FromNewton(0, 10, 0);
Velocity3D<double> v = Velocity3D<double>.FromMeterPerSecond(0, 10, 0);

var tau = r.Cross(f); // CS1503: cannot convert Force3D<double> to Position3D<double>
var h   = r.Cross(v); // CS1503

Today callers have to write ((Displacement3D<double>)r).Cross(f). Translation3D has the same gap, and so will any future vector overload of a dimension that has typed products. An overload on the argument side already works, because the argument widens.

Suggested fix / acceptance criteria

Activity

  1. matt-edmondson commented on Oct 30, 2026

    @matt-edmondson
    ContributorAuthor

    Triage


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions