Skip to content

Commit 7629310

Browse files
committed
Added features requested in #154
1 parent 3f9339f commit 7629310

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/core/modules/mathlib/mathlib.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ class VectorExt
7272

7373
static str __repr__(Vector* pVector)
7474
{ return str("Vector" + str(tuple(pVector))); }
75+
76+
static Vector Copy(Vector* pVec)
77+
{ return *pVec; }
78+
79+
static Vector Normalized(Vector* pVec)
80+
{
81+
Vector copy = *pVec;
82+
copy.NormalizeInPlace();
83+
return copy;
84+
}
7585
};
7686

7787

src/core/modules/mathlib/mathlib_wrap.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,17 @@ void export_vector(scope _mathlib)
165165

166166
.def("normalize",
167167
&Vector::NormalizeInPlace,
168-
"Normalizes the vector."
168+
"Normalize the vector inplace and return its length before normalization."
169+
)
170+
171+
.def("normalized",
172+
&VectorExt::Normalized,
173+
"Return a normalized copy of the vector."
174+
)
175+
176+
.def("copy",
177+
&VectorExt::Copy,
178+
"Return a copy of the vector."
169179
)
170180

171181
.def("is_length_greater_than",

0 commit comments

Comments
 (0)