Skip to content

Commit

Permalink
Added magnitude, normalized, and direction_to function to Vector2 in …
Browse files Browse the repository at this point in the history
…python-api.
  • Loading branch information
Chukobyte committed Jan 12, 2022
1 parent 25d7460 commit 52592f3
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/core/scripting/python/python_source.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef PYTHON_SOURCE_H
#define PYTHON_SOURCE_H

// Seika Engine API v0.13.2
// Seika Engine API v0.14.0

using PythonSource = const std::string&;

Expand Down Expand Up @@ -539,6 +539,18 @@ static PythonSource PYTHON_SOURCE_MATH_MODULE =
" def __repr__(self):\n"
" return f\"({self.x}, {self.y})\"\n"
"\n"
" def magnitude(self) -> float:\n"
" return math.sqrt(self.x * self.x + self.y * self.y)\n"
"\n"
" def normalized(self):\n"
" mag = self.magnitude()\n"
" self.x = self.x / mag\n"
" self.y = self.y / mag\n"
" return self\n"
"\n"
" def direction_to(self, target):\n"
" return (target - self).normalized()\n"
"\n"
" @staticmethod\n"
" def lerp(source, destination, amount: float) -> float:\n"
" return source + (destination - source) * Vector2(amount, amount)\n"
Expand Down

0 comments on commit 52592f3

Please sign in to comment.