Skip to content

Commit 49ad3d8

Browse files
committed
Added unary negative operation to Vector.
1 parent 2be52a7 commit 49ad3d8

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/core/modules/mathlib/mathlib.h

100644100755
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ class VectorExt
9494
vecCopy -= val;
9595
return vecCopy;
9696
}
97+
98+
static inline Vector __neg__(Vector vecCopy)
99+
{
100+
vecCopy.Negate();
101+
return vecCopy;
102+
}
97103
};
98104

99105

src/core/modules/mathlib/mathlib_wrap.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ void export_vector(scope _mathlib)
158158
.def("__radd__", &VectorExt::__add__)
159159
.def(float() * self)
160160

161+
.def("__neg__", &VectorExt::__neg__)
162+
161163
.def("negate",
162164
&Vector::Negate,
163165
"Negates the vector."

0 commit comments

Comments
 (0)