tjstienstra / symmeplot

Sympy Mechanics Plotter
https://tjstienstra.github.io/symmeplot/
MIT License
5 stars 1 forks source link

Feature request: 2D plotting #13

Closed tjstienstra closed 3 months ago

tjstienstra commented 1 year ago

Describe the feature you'd like An awesome feature would be to also make projections to planes, such that you can easily make 2D plots.

To what module is your feature request related? The projection should be made in the core. The backends will most probably also require a new Scene2D class.

MarkVerbeek91 commented 3 months ago

as starting tip: a 2D plot can already achievable using custom axes with an orthogonal projection and a custom view location. Using this ax definition you will get the (crude) 2D plot.

_, ax = plt.subplots(subplot_kw={"projection": "3d", "proj_type": "ortho"})
ax.view_init(elev=90, azim=0, roll=90)
scene = Scene3D(N, P, scale=0.5, ax=ax)  # N = reference frame, P = Point

It does not have the nice axes as a normal 2d plot would have but it works for me, for now.

tjstienstra commented 3 months ago

Good point. Something like this could be a nice feature to make it simpler for a user.

class Scene3D(SceneBase):
    ...
    def project_as_2d(self, frame=None) -> None:
        """Change the axis to an orhogonal projection making the view seemingly 2D.

        Parameters
        ----------
        frame: ReferenceFrame, optional
            Reference frame w.r.t. which the axis view is oriented aligning the users view
            with the XY plane. The default is the intertial frame of the scene.
        """
        self.ax.set_proj_type('ortho')
        self.ax.view_init(elev=90, azim=-90, roll=0)