
This relatively simple operation has been remarkably difficult for me to define.
float Foo(this float lhs, float rhs) => lhs * rhs.Sign();
It is intended to reframe lhs in the context of rhs's direction. For example, determining how much of the velocity of a videogame character is in the same direction as the player's input.
It serves a similar function to a scalar projection in one dimension.
Ṁ20 - I want a name that will be reasonably memorable, and short.
Ṁ30 - I want a simple one-sentence description that provides a perspective to think about it from, rather than just explaining what it does. (Similar to how one thinks of matrix multiplications as affine transformations, and not just a load of dot products.)
Well, by a software engineering perspective, I think it's kinda a shitty operator...
Anyway I would create a:
signAgreement(float num1, float num2)
return num1 * num2 > 0;
And then you do:
ConditionalSignAlignment(float num, boolean condition)
return condition? num : -num;
Client:
Speed = ConditionalSignAlignment(Speed, signAgreement (Speed, speed2);
Java code
May be easier with other languages.