physics

python ball physics simulation

北战南征 提交于 2019-12-30 06:30:32
问题 I have seen the great tutorial by Peter Colling Ridge on http://www.petercollingridge.co.uk/pygame-physics-simulation/ and I am extending the PyParticles script The code is available on the site(for free), I am using PyParticles4.py Classes used in the tutorial The Particle Class Circular 2d objects with radius,mass,velocity,location The Spring Class A spring that binds 2 objects (Particles) and uses the Hooke's law (F = -kx) to determine the interaction between them The Environment Class The

Significant figures in the decimal module

故事扮演 提交于 2019-12-29 08:40:14
问题 So I've decided to try to solve my physics homework by writing some python scripts to solve problems for me. One problem that I'm running into is that significant figures don't always seem to come out properly. For example this handles significant figures properly: from decimal import Decimal >>> Decimal('1.0') + Decimal('2.0') Decimal("3.0") But this doesn't: >>> Decimal('1.00') / Decimal('3.00') Decimal("0.3333333333333333333333333333") So two questions: Am I right that this isn't the

Audio analysis: frequency vs pitch [closed]

偶尔善良 提交于 2019-12-29 06:26:13
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 12 months ago . I'm designing a simple tuner, so my target is displaying a note name (A, B, F#) and the distance in cents between the theoretic sound and the actual input. I'm completely new to audio and signal processing, so I did some research and I found a thing called Fast Fourier Transform that will analyze the bytes and

Can't flip direction of ball without messing up gravity

别等时光非礼了梦想. 提交于 2019-12-29 02:12:09
问题 I am making a game like pong except that there is only one paddle and the ball moves in projectile motion. The goal is to keep the ball bouncing on your paddle for as long as possible. I when I have the ball hit the paddle the direction of the y component of the velocity has it's sign flipped. The issue with this is that when the ball is moving up gravity acts upon in in that direction, speeding it up. The code is below This is the code for my ball class, this is the tick method which is

Can't flip direction of ball without messing up gravity

你说的曾经没有我的故事 提交于 2019-12-29 02:12:07
问题 I am making a game like pong except that there is only one paddle and the ball moves in projectile motion. The goal is to keep the ball bouncing on your paddle for as long as possible. I when I have the ball hit the paddle the direction of the y component of the velocity has it's sign flipped. The issue with this is that when the ball is moving up gravity acts upon in in that direction, speeding it up. The code is below This is the code for my ball class, this is the tick method which is

How to code the projectile of a ball of different force and angle in Java Swing?

帅比萌擦擦* 提交于 2019-12-28 03:05:18
问题 I have written the following function for projectile motion of different force and angle, but it doesn't work properly. Where have I gone wrong? I want something like the Angry Birds game. Code: public void shootBall(int timeCounter){ int gravity = 4; double time = timeCounter/40.0; int velocity = force_value; double radians = currentangle*Math.PI/180; ball.setX((int)((ball.getX()+10)*Math.cos(radians) + velocity*Math.cos(radians)*time)); ball.setY((int)((ball.getY()+10)*Math.sin(radians) +

How to code the projectile of a ball of different force and angle in Java Swing?

北战南征 提交于 2019-12-28 03:05:14
问题 I have written the following function for projectile motion of different force and angle, but it doesn't work properly. Where have I gone wrong? I want something like the Angry Birds game. Code: public void shootBall(int timeCounter){ int gravity = 4; double time = timeCounter/40.0; int velocity = force_value; double radians = currentangle*Math.PI/180; ball.setX((int)((ball.getX()+10)*Math.cos(radians) + velocity*Math.cos(radians)*time)); ball.setY((int)((ball.getY()+10)*Math.sin(radians) +

iOS 7 Sprite Kit freeing up memory

一个人想着一个人 提交于 2019-12-27 11:59:38
问题 I am building an iOS game aimed for the new iOS 7 and Sprite Kit, using emitter nodes and physics to enhance gameplay. While developing the app, I ran into a serious problem: you create your scenes, nodes, effects, but when you are done and need to return to the main screen, how do you free up all the memory allocated by these resources? Ideally ARC should free up everything and the application should get back to the memory consumption level it had before creating the scene, but this is not

Creating Huge Sparse Matrices in python

為{幸葍}努か 提交于 2019-12-25 09:29:42
问题 I have been using normal matrices from numpy to store a Matrix for a physics project. The size of the matrix is determined by the physical system. So for instance if the system has parameters: L=4 and N =2, then the matrix is of dimension 4C2 = 6, so the matrix is a 6x6 matrix. This is fine except for now I need larger size i.e 20C10 = 184,756. So the matrix required is now a 184756x184756 matrix, which when I try to create an empty matrix of this size gives me a memory error. (with 16GB of

THREE.js: Can you force a different order of operations for three.js?

谁都会走 提交于 2019-12-25 04:34:22
问题 See this question: Threejs Transform Matrix ordering I'm drawing the orbits of the planets and having problem with changing inertial reference frames (I chose to align the three.js world coordinates with the viewed planet's inertial reference frame). But I need to force three.js to apply operations in the order shown below so the orbit is properly displayed (presently the orbit stays at world (0,0,0) and spins crazily). The normal (physics) way to do this is to do the following in order: 1.