Skip to content

Commit

Permalink
pybricks.geometry: add 3x3 identity matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
laurensvalk committed Jan 5, 2021
1 parent da9bd26 commit 4d0e68f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions pybricks/geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ typedef struct _pb_type_Matrix_obj_t {
const pb_type_Matrix_obj_t pb_Axis_X_obj;
const pb_type_Matrix_obj_t pb_Axis_Y_obj;
const pb_type_Matrix_obj_t pb_Axis_Z_obj;
const pb_type_Matrix_obj_t pb_Matrix_identity3_obj;

mp_obj_t pb_type_Matrix_make_vector(size_t m, float *data, bool normalize);

Expand Down
14 changes: 14 additions & 0 deletions pybricks/geometry/pb_module_geometry.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ const pb_type_Matrix_obj_t pb_Axis_Z_obj = {
.n = 1,
};

STATIC const float pb_Matrix_identity3_data[] = {
1.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 1.0f,
};

const pb_type_Matrix_obj_t pb_Matrix_identity3_obj = {
{&pb_type_Matrix},
.data = (float *)pb_Matrix_identity3_data,
.scale = 1.0f,
.m = 3,
.n = 3,
};

STATIC const mp_rom_map_elem_t pb_Axis_table[] = {
{ MP_ROM_QSTR(MP_QSTR_X), MP_ROM_PTR(&pb_Axis_X_obj)},
{ MP_ROM_QSTR(MP_QSTR_Y), MP_ROM_PTR(&pb_Axis_Y_obj)},
Expand Down

0 comments on commit 4d0e68f

Please sign in to comment.