Python Physics Sandbox released
I'm very pleased to announce the general release of a Python physics sandbox targeting students in intro programming courses. We teach Python as a first language here and a physics simulation has long been one of the students' favorite labs. But the simulation we were using, while easy to use, was pretty limited and only worked in one particular IDE. So I wrote PyPhysicsSandbox, a thin wrapper around pymunk. The sandbox allows students to construct more sophisticated combinations of shapes and joints and interactivity with the user. It should also work in any environment that allows installing libraries to Python using pip. The code lives here: https://github.com/jshaffstall/PyPhysicsSandbox It's freely available for use in your own classes. Jay
Hi, This looks great, and I hadn't seen pymunk before. I tried a quick simulation, and it's working: import pyphysicssandbox as ps ps.window("ball", 600, 400) b1 = ps.ball((100, 0), 30) ps.run() How do I give the ball a horizontal velocity? Eric On Tue, Dec 13, 2016 at 5:46 AM, Jay Shaffstall <jshaffstall@gmail.com> wrote:
I'm very pleased to announce the general release of a Python physics sandbox targeting students in intro programming courses. We teach Python as a first language here and a physics simulation has long been one of the students' favorite labs. But the simulation we were using, while easy to use, was pretty limited and only worked in one particular IDE.
So I wrote PyPhysicsSandbox, a thin wrapper around pymunk. The sandbox allows students to construct more sophisticated combinations of shapes and joints and interactivity with the user. It should also work in any environment that allows installing libraries to Python using pip.
The code lives here: https://github.com/jshaffstall/PyPhysicsSandbox
It's freely available for use in your own classes.
Jay
_______________________________________________ Edu-sig mailing list Edu-sig@python.org https://mail.python.org/mailman/listinfo/edu-sig
Hi Eric, Glad the sandbox is working for you! You've got a couple of options for giving the ball a horizontal velocity, depending on what effect you want. If you want an instantaneous horizontal kick, but after that the ball responds normally to gravity, use b1.hit and set the y part of the direction tuple to 0. If you want the ball to fall horizontally use b1.gravity and again set the y part of the gravity to 0. If what you're looking for is a constant velocity, there isn't any way to do that right now, but you might play with the ball's gravity and damping values to see if you can get the right effect. This is just a first version, so if you see features you'd like, let me know. Take care, Jay On Wed, Dec 14, 2016 at 10:40 AM, Eric Matthes <ehmatthes@gmail.com> wrote:
Hi,
This looks great, and I hadn't seen pymunk before. I tried a quick simulation, and it's working:
import pyphysicssandbox as ps ps.window("ball", 600, 400)
b1 = ps.ball((100, 0), 30) ps.run()
How do I give the ball a horizontal velocity?
Eric
On Tue, Dec 13, 2016 at 5:46 AM, Jay Shaffstall <jshaffstall@gmail.com> wrote:
I'm very pleased to announce the general release of a Python physics sandbox targeting students in intro programming courses. We teach Python as a first language here and a physics simulation has long been one of the students' favorite labs. But the simulation we were using, while easy to use, was pretty limited and only worked in one particular IDE.
So I wrote PyPhysicsSandbox, a thin wrapper around pymunk. The sandbox allows students to construct more sophisticated combinations of shapes and joints and interactivity with the user. It should also work in any environment that allows installing libraries to Python using pip.
The code lives here: https://github.com/jshaffstall/PyPhysicsSandbox
It's freely available for use in your own classes.
Jay
_______________________________________________ Edu-sig mailing list Edu-sig@python.org https://mail.python.org/mailman/listinfo/edu-sig
On Wed, Dec 14, 2016 at 10:54 AM, Jay Shaffstall <jshaffstall@gmail.com> wrote:
If what you're looking for is a constant velocity, there isn't any way to do that right now, but you might play with the ball's gravity and damping values to see if you can get the right effect.
Is gravity global to the scene? Maybe it could be toggled on and off, given zero-G physics as an option?
This is just a first version, so if you see features you'd like, let me know.
I was gonna mention this on a physics learning list I'm on but got lost looking for the physics engine you're using. Something embedded in the Calico IDE? I'd not heard of that before, but have so far watched one Youtube about it. If you have any Youtubes or screencasts of your project in action, I'm keen to view. Could be I missed a link at your Github. I'm mostly familiar with physics teachers using VPython, which got started and gets maintained by the physics-oriented. Kirby
If what you're looking for is a constant velocity, there isn't any way to
do that right now, but you might play with the ball's gravity and damping values to see if you can get the right effect.
Is gravity global to the scene? Maybe it could be toggled on and off, given zero-G physics as an option?
The scene itself has a gravity vector, and each object can have its own gravity vector set. So the scene can be set to (0, 0) gravity so everything stays in place except for interactions between shapes. I haven't played with that, but I like the idea of zero-G physics simulations. The damping value can be modified to simulate air resistance.
This is just a first version, so if you see features you'd like, let me
know.
I was gonna mention this on a physics learning list I'm on but got lost looking for the physics engine you're using. Something embedded in the Calico IDE? I'd not heard of that before, but have so far watched one Youtube about it.
PyPhysicsSandbox is independent of Calico. Calico has a physics engine of its own, which is based on the Farseer physics engine, which is based on Box2d. PyPhysicsSandbox is a layer on top of Pymunk, which is a Python binding to the Chipmunk physics library. The sandbox is independent of any IDE.
If you have any Youtubes or screencasts of your project in action, I'm keen to view. Could be I missed a link at your Github.
I have one video that was from an early version. Creating more actual tutorial videos is on my todo list. Here's that one: https://www.youtube.com/watch?v=ZeZMvNSH62k Jay
If you have any Youtubes or screencasts of your project in action, I'm keen to view. Could be I missed a link at your Github.
I created a YouTube channel for tutorial screencasts. Just a Hello World type one up there now, but over time I'll add more to explore other features of the sandbox. The channel's now linked in the README file on GitHub, or the direct link is: https://www.youtube.com/channel/UCybNk1XwGtiPyiLVitMFmsQ Jay <https://www.youtube.com/channel/UCybNk1XwGtiPyiLVitMFmsQ>
Thanks for doing all this. I mentioned this thread to a physics listserv frequented by those looking in to effectively teaching same [1]. Your project is geared to students learning to code, which could include future physics engine designers. Great way to get one's feet wet, not just using the code but looking over your shoulder at how it's developed, who knows even contributing. Kirby [1] called PHYSLRNR closed archive, hosted University of Buffalo. I was invited to join even though I'm not a physics teacher by the late Dr. Bob Fuller, an eminent physics teacher based at University of Nebraska, Lincoln campus. I got to meet and work with him on what we called a "First Person Physics" curriculum angle. On Fri, Dec 16, 2016 at 6:05 PM, Jay Shaffstall <jshaffstall@gmail.com> wrote:
If you have any Youtubes or screencasts of your project in action, I'm keen to view. Could be I missed a link at your Github.
I created a YouTube channel for tutorial screencasts. Just a Hello World type one up there now, but over time I'll add more to explore other features of the sandbox.
The channel's now linked in the README file on GitHub, or the direct link is: https://www.youtube.com/channel/UCybNk1XwGtiPyiLVitMFmsQ
Jay <https://www.youtube.com/channel/UCybNk1XwGtiPyiLVitMFmsQ>
How do I give the ball a horizontal velocity?
The 1.4 development branch on github now has the ability to set a constant velocity for a shape. For example, to move it horizontally right you could use: ball1.velocity = (50, 0) I won't be releasing 1.4 to PyPi until I've tracked down a bug with custom shape gravity, but you can clone the repository and copy the files over to your site-packages/pyphysicssandbox directory to use the newer version. There are also a lot of screencasts on the YouTube channel covering most aspects of the version 1.3 sandbox: https://www.youtube.com/channel/UCybNk1XwGtiPyiLVitMFmsQ Jay
Version 1.4 has been released and is available for the standard pip install. Constant velocity was added, along with fixing the bug with shape specific gravity. Jay On Wed, Dec 28, 2016 at 2:13 PM, Jay Shaffstall <jshaffstall@gmail.com> wrote:
How do I give the ball a horizontal velocity?
The 1.4 development branch on github now has the ability to set a constant velocity for a shape. For example, to move it horizontally right you could use:
ball1.velocity = (50, 0)
I won't be releasing 1.4 to PyPi until I've tracked down a bug with custom shape gravity, but you can clone the repository and copy the files over to your site-packages/pyphysicssandbox directory to use the newer version.
There are also a lot of screencasts on the YouTube channel covering most aspects of the version 1.3 sandbox: https://www.youtube.com/channel/ UCybNk1XwGtiPyiLVitMFmsQ
Jay
participants (3)
-
Eric Matthes
-
Jay Shaffstall
-
kirby urner