The function below works, but it consumes its arguments. Is there some way to write an operator function that just borrows its arguments? Preferably without having to write
let x = (&y) * (&z);
to invoke the operator.
/// Multiply by matrix, V*M form. Rotates, scales, translates vector by matrix
impl ops::Mul<LLMatrix4> for LLVector3 {
type Output = LLVector3;
fn mul(self, rhs: LLMatrix4) -> LLVector3 {
// Operate "to the left" on row-vector a
LLVector3 {
x: self.x * rhs.m[0][0] +
self.y * rhs.m[1][0] +
self.z * rhs.m[2][0] +
1.0 * rhs.m[3][0],
y: self.x * rhs.m[0][1] +
self.y * rhs.m[1][1] +
self.z * rhs.m[2][1] +
1.0 * rhs.m[3][1],
z: self.x * rhs.m[0][2] +
self.y * rhs.m[1][2] +
self.z * rhs.m[2][2] +
1.0 * rhs.m[3][2],
}
}
}