mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-21 12:00:18 +00:00
...
This commit is contained in:
parent
764c699ce4
commit
a7232722ec
22
src/mat3x3.h
22
src/mat3x3.h
@ -172,13 +172,7 @@ struct Mat3x3{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************** affine transform ***************/
|
/*************** affine transformations ***************/
|
||||||
bool is_affine() const{
|
|
||||||
float det = _11 * _22 - _12 * _21;
|
|
||||||
if(fabsf(det) < kEpsilon) return false;
|
|
||||||
return _31 == 0.0f && _32 == 0.0f && _33 == 1.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Mat3x3 translate(Vec2 v){
|
static Mat3x3 translate(Vec2 v){
|
||||||
return Mat3x3(1.0f, 0.0f, v.x,
|
return Mat3x3(1.0f, 0.0f, v.x,
|
||||||
0.0f, 1.0f, v.y,
|
0.0f, 1.0f, v.y,
|
||||||
@ -213,6 +207,12 @@ struct Mat3x3{
|
|||||||
0.0f, 0.0f, 1.0f);
|
0.0f, 0.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_affine() const{
|
||||||
|
float det = _11 * _22 - _12 * _21;
|
||||||
|
if(fabsf(det) < kEpsilon) return false;
|
||||||
|
return _31 == 0.0f && _32 == 0.0f && _33 == 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
Mat3x3 inverse_affine() const{
|
Mat3x3 inverse_affine() const{
|
||||||
Mat3x3 ret;
|
Mat3x3 ret;
|
||||||
float det = _11 * _22 - _12 * _21;
|
float det = _11 * _22 - _12 * _21;
|
||||||
@ -593,6 +593,14 @@ struct PyMat3x3: Mat3x3{
|
|||||||
return VAR_T(PyMat3x3, Mat3x3::trs(t, r, s));
|
return VAR_T(PyMat3x3, Mat3x3::trs(t, r, s));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
vm->bind_func<4>(type, "ortho", [](VM* vm, ArgsView args){
|
||||||
|
f64 left = vm->num_to_float(args[0]);
|
||||||
|
f64 right = vm->num_to_float(args[1]);
|
||||||
|
f64 bottom = vm->num_to_float(args[2]);
|
||||||
|
f64 top = vm->num_to_float(args[3]);
|
||||||
|
return VAR_T(PyMat3x3, Mat3x3::ortho(left, right, bottom, top));
|
||||||
|
});
|
||||||
|
|
||||||
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());
|
||||||
|
@ -58,6 +58,8 @@ class mat3x3:
|
|||||||
def ones() -> mat3x3: ...
|
def ones() -> mat3x3: ...
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def identity() -> mat3x3: ...
|
def identity() -> mat3x3: ...
|
||||||
|
@staticmethod
|
||||||
|
def ortho(left: float, right: float, bottom: float, top: float) -> mat3x3: ...
|
||||||
|
|
||||||
# affine transformations
|
# affine transformations
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
Loading…
x
Reference in New Issue
Block a user