From 4be37e447c0bf8df671e29e6741e3f38ef9e5509 Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Wed, 9 Oct 2024 01:45:42 -0300 Subject: [PATCH] ENH: make the Matrix class JSON serializable --- rocketpy/mathutils/vector_matrix.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rocketpy/mathutils/vector_matrix.py b/rocketpy/mathutils/vector_matrix.py index 60032793c..0da44935d 100644 --- a/rocketpy/mathutils/vector_matrix.py +++ b/rocketpy/mathutils/vector_matrix.py @@ -1002,6 +1002,10 @@ def __repr__(self): + f" [{self.zx}, {self.zy}, {self.zz}])" ) + def to_dict(self): + """Returns the matrix as a JSON compatible element.""" + return [list(row) for row in self.components] + @staticmethod def identity(): """Returns the 3x3 identity matrix."""