Skip to content

Commit 3615aec

Browse files
Merge pull request #584 from schwarrrtz/master
* operator on C4Vector now works with the scalar on the left hand side
2 parents fa88e3f + 97ce221 commit 3615aec

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Diff for: C4/Core/C4Vector.swift

+13
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,19 @@ public func * (lhs: C4Vector, rhs: Double) -> C4Vector {
331331
return C4Vector(x: lhs.x * rhs, y: lhs.y * rhs, z: lhs.z * rhs)
332332
}
333333

334+
335+
/// Returns a new vector whose coordinates are the multiplication of the right-hand vector coordinates by the left-hand scalar
336+
///
337+
/// ````
338+
/// var v1 = C4Vector(x: 1, y: 1)
339+
/// var v2 = 2.0 * v2
340+
/// v2 //-> {2,2,0}
341+
///
342+
public func * (lhs: Double, rhs: C4Vector) -> C4Vector {
343+
return C4Vector(x: rhs.x * lhs, y: rhs.y * lhs, z: rhs.z * lhs)
344+
}
345+
346+
334347
/// Returns a new vector whose coordinates are the negative values of the receiver
335348
///
336349
/// ````

0 commit comments

Comments
 (0)