Unity needs to add multiply operator into its Vector structs.
It would be so nice if Unity would update its math library to support multiplication so I don’t have to use a static method just to short hand the code.
The Vector3.Scale() function already exists.
I think the reason that they chose this name is to avoid confusing vector multiplication with “cross product” and “dot product” which are the first thing that mathematicians would think when you say you want to multiply vectors.
As halley alluded to, there’s actually at least three different operations that one might reasonably consider “multiplication” of two Vectors:
- Dot product
- Cross product
- hadamard product / aka Vector3.Scale
Having one of these three get to use the * operator would probably just lead to more confusion.
Yes, that’s usually the reason behind this decision. Though if you want a math library that is closer to the usual CG \ hlsl shader syntax you can use unity’s mathematics package and the types that come with it. Like float3.
This library was designed with high compatibility between shader code and C# code and to be burst compiler friendly. It does support the component wise (hadamard) product as the default multiplication.
However since it’s a separate library, there is some casting required between the mathematics types and the build in types like Vector3
Using the ‘*’ operator in matrix, quat or vector for complex multiplication is actually the incorrect place to handle these special ops & out of line with other principles in modern lang design.
This is a software lang not a mathematical one from 2000 BC. Its tools to describe meaning aren’t limited to short hands to save paper.
Regardless I’ll stick to Vector3.Scale in Unity.