mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
...
This commit is contained in:
parent
46eadebfc0
commit
bb55200ea2
@ -76,7 +76,7 @@ struct NumberTraits<4> {
|
|||||||
|
|
||||||
static constexpr int_t kMaxSmallInt = (1 << 28) - 1;
|
static constexpr int_t kMaxSmallInt = (1 << 28) - 1;
|
||||||
static constexpr int_t kMinSmallInt = - (1 << 28);
|
static constexpr int_t kMinSmallInt = - (1 << 28);
|
||||||
static constexpr float_t kEpsilon = 1e-4;
|
static constexpr float_t kEpsilon = (float_t)1e-4;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
@ -86,7 +86,7 @@ struct NumberTraits<8> {
|
|||||||
|
|
||||||
static constexpr int_t kMaxSmallInt = (1ll << 60) - 1;
|
static constexpr int_t kMaxSmallInt = (1ll << 60) - 1;
|
||||||
static constexpr int_t kMinSmallInt = - (1ll << 60);
|
static constexpr int_t kMinSmallInt = - (1ll << 60);
|
||||||
static constexpr float_t kEpsilon = 1e-8;
|
static constexpr float_t kEpsilon = (float_t)1e-8;
|
||||||
};
|
};
|
||||||
|
|
||||||
using Number = NumberTraits<sizeof(void*)>;
|
using Number = NumberTraits<sizeof(void*)>;
|
||||||
|
@ -118,6 +118,8 @@ class mat3x3(_StructLike['mat3x3']):
|
|||||||
# affine transformations
|
# affine transformations
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def trs(t: vec2, r: float, s: vec2) -> mat3x3: ...
|
def trs(t: vec2, r: float, s: vec2) -> mat3x3: ...
|
||||||
|
|
||||||
|
def set_trs(self, t: vec2, r: float, s: vec2) -> None: ...
|
||||||
|
|
||||||
def is_affine(self) -> bool: ...
|
def is_affine(self) -> bool: ...
|
||||||
|
|
||||||
|
@ -453,12 +453,21 @@ static Vec2 SmoothDamp(Vec2 current, Vec2 target, PyVec2& currentVelocity, float
|
|||||||
/*************** affine transformations ***************/
|
/*************** affine transformations ***************/
|
||||||
// @staticmethod
|
// @staticmethod
|
||||||
vm->bind(type, "trs(t: vec2, r: float, s: vec2)", [](VM* vm, ArgsView args){
|
vm->bind(type, "trs(t: vec2, r: float, s: vec2)", [](VM* vm, ArgsView args){
|
||||||
PyVec2& t = CAST(PyVec2&, args[0]);
|
Vec2 t = CAST(Vec2, args[0]);
|
||||||
f64 r = CAST_F(args[1]);
|
f64 r = CAST_F(args[1]);
|
||||||
PyVec2& s = CAST(PyVec2&, args[2]);
|
Vec2 s = CAST(Vec2, args[2]);
|
||||||
return VAR_T(PyMat3x3, Mat3x3::trs(t, r, s));
|
return VAR_T(PyMat3x3, Mat3x3::trs(t, r, s));
|
||||||
}, {}, BindType::STATICMETHOD);
|
}, {}, BindType::STATICMETHOD);
|
||||||
|
|
||||||
|
vm->bind(type, "set_trs(self, t: vec2, r: float, s: vec2)", [](VM* vm, ArgsView args){
|
||||||
|
PyMat3x3& self = _CAST(PyMat3x3&, args[0]);
|
||||||
|
Vec2 t = CAST(Vec2, args[1]);
|
||||||
|
f64 r = CAST_F(args[2]);
|
||||||
|
Vec2 s = CAST(Vec2, args[3]);
|
||||||
|
self = Mat3x3::trs(t, r, s);
|
||||||
|
return vm->None;
|
||||||
|
});
|
||||||
|
|
||||||
vm->bind_method<0>(type, "is_affine", [](VM* vm, ArgsView args){
|
vm->bind_method<0>(type, "is_affine", [](VM* vm, ArgsView args){
|
||||||
PyMat3x3& self = _CAST(PyMat3x3&, args[0]);
|
PyMat3x3& self = _CAST(PyMat3x3&, args[0]);
|
||||||
return VAR(self.is_affine());
|
return VAR(self.is_affine());
|
||||||
|
@ -424,6 +424,9 @@ radian = random.uniform(-10*math.pi, 10*math.pi)
|
|||||||
|
|
||||||
assert mat_to_str_list(mat3x3.trs(test_vec2_copy, radian, test_vec2_2_copy)) == mat_list_to_str_list(trs(test_vec2_list, radian, test_vec2_2_list))
|
assert mat_to_str_list(mat3x3.trs(test_vec2_copy, radian, test_vec2_2_copy)) == mat_list_to_str_list(trs(test_vec2_list, radian, test_vec2_2_list))
|
||||||
|
|
||||||
|
a = mat3x3.zeros()
|
||||||
|
a.set_trs(test_vec2_copy, radian, test_vec2_2_copy)
|
||||||
|
assert a == mat3x3.trs(test_vec2_copy, radian, test_vec2_2_copy)
|
||||||
|
|
||||||
# test is_affine
|
# test is_affine
|
||||||
def mat_is_affine(mat_list):
|
def mat_is_affine(mat_list):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user