The bitmask is on 32 bits. Declaring them like you did corresponds to : enum CollisionType:UInt32{ case Bird = 1 // 00000000000000000000000000000001 case Coin = 2 // 00000000000000000000000000000010 case Border = 3 // 00000000000000000000000000000011 } What you want to do is to set your border value to 4. In order...

swift,colors,sprite-kit,physics,skspritenode

If a physics body's dynamic property is true, the outline will be blue. If it is false, the outline will be green. You cannot manually set the color.

This is easy to explain: You are implementing Euler forward as solver for the ODE, and in mechanical systems the systematic error of Euler forward increases the energy. Euler backward decreases the energy, so a combination of alternating the explicit and implicit Euler methods would leave the energy a little...

box2d,physics,units-of-measurement,physics-engine,farseer

Every thing you specify in physics will have units. If you decide that physics is working in meters and your editor works in pixels then you will need to convert everything that has meters in its units. It is probably easiest to just write them all out. position: m velocity:...

rotation is form of kinetic energy first the analogy to movement alpha - angular position [rad] omega - angular speed [rad/s] epsilon - angular acceleration [rad/s^2] alpha(t)/(dt^2)=omega(t)/dt=epsilon(t) now the inertia I - quadratic rotation mass inertia [kg.m^2] m - mass [kg] M - torque [N.m] and some equations to be...

I think the problem is that in each of your iterations, you are not re-calculating J2 and Jeq. Now, your model is parameterised with J1, J2 and Jz so these are the values you need to update with each iteration. Something like: a2 = 0:J1; % do you really want...

python,physics,numeric,curve-fitting

The problem is that scipy.optimize.curve_fit expects zfc to work on array arguments, i.e. given an n-array of x-values and 3 n-arrays of k1,k2,k3 values the zfc(x,k1,k2,k3) should return an n-array containing the corresponding values of the function. This can however easily be achieved by creating a wrapper for the function...

It seems I found the problem. I solved it by replacing the line MotionState motion = new DefaultMotionState(new Transform()); by Transform transform = new Transform(); transform.setIdentity(); MotionState motion = new DefaultMotionState(transform); It looks like Transform's default Constructor won't create an identity Transform as I'd expect....

java,libgdx,physics,game-physics,orthographic

By "experimentally determined," the author just means trying various values until finding something that worked. There's no math or complex magic here. To experiment with it, just change it and run the program again. If you like what you see, use it. If not, adjust it accordingly. The number of...

python,numpy,matplotlib,graph,physics

Fixed Equation def E(wt, Q): return np.exp(-x/float(Q)) * ( 1. - (1./2./float(Q))*np.sin(2.* x) ) Your original equation def E(wt, Q): return (np.e**(-x/Q))*(1-(1/2*Q)*np.sin(2*x)) Errors Unused Variables You never use wt BODMAS You don't have a decay parameter set up correctly, so it will oscillate too much. (1/2*Q) when you mean (1/2/Q)...

I found the answer here at math.stackexchange.com. Thanks to Hristo Iliev who helped me sort it out. A working example (code in Haxe) looks like this: class BeatDurationCalculator { /** * Calculates the time duration for individual musical beats in a tempo changing context. * Example: What is the duration...

ios,objective-c,sprite-kit,accelerometer,physics

I assume that you have your collision bit masks properly set up to handle collisions. You should confirm this with a test to double check. I believe your issue is with the speed of your object. If the object is moving too fast, and I do not see any velocity...

The problem here is that you are essentially applying small bursts of force to the ball, discretely. Even though you are scaling the momentum down, you are constantly adding this value of 0.2 to the ball's momentum. As an analogy, what you are doing by periodically applying gravity, is tapping...

ios,sprite-kit,physics,game-physics,skphysicsbody

A node does not remove itself from the view once it goes off screen. It's still there but no longer gets rendered. If it has a physics body, physics calculations are still ongoing despite being off screen. The only instance a node gets removed is if you remove it from...

swift,collision-detection,physics,collision,contact

You need to make GameScene conform to SKPhysicsContactDelegate, like so: class GameScene: SKScene, SKPhysicsContactDelegate { // ... } Now you can implement the delegate methods you want, all the methods in SKPhysicsContactDelegate are optional, and they'll get called at the appropriate time. For more information on Protocols, I would recommend...

python,python-2.7,numpy,scipy,physics

There are just two typos standing in your way. First for i in range(len(positions)/2): only iterates over half of your particles. This is why half the particles stay in the x bounds (if you watch for large iterations its more clear). Second, the second y condition should be a minimum...

I'm not sure if you're concerned about how to draw a convincing elastic band onscreen, or how to emulate the physics of one. If it's the former I can't help you much, but if it's the latter you could try something like this! You should be able to copy and...

It's probably not every millisecond, but instead every frame, and that's why you likely end up with numbers like +23 (The collision is taking place for a 1/3 of a second and if it's running at 60 FPS that is about 20 or so frames). One thing you could do...

^ is a bitwise xor operator in PHP, not an exponential operator use pow($lightspeed*299792458,2) and pow(299792458,2) instead...

You accidentally placed touchesMoved, touchesEnded and update inside touchesBegan. Besides that your code works. A hint that there were problems was the fact you didn't need to prefix touchesMoved, touchesEnded or update with override. In the future, I would recommend using breakpoints and print statements to check the methods you...

I apologize to those who posted on this for my delayed response. I found a solution that worked for me. Below is the approach I took. Find the target height that the object should reach after it hits the ground (bottom of screen). //We want the object to bounce halfway...

Yes, you need to create a child GameObject, with a trigger collider, and put it in a layer that interacts with the player layer. No, you don't need to add a Rigidbody to the new GameObject, the parent's rigidbody already makes it a dynamic collider, so you will get OnTrigger...

I think you explicitly need to call world.DrawDebugData(). Also, did you know you can call SetFlags(a | b | c); instead of AppendFlags(a); AppendFlags(b); AppendFlags(c);?...

c++,camera,orientation,physics

Solved it. Needed a different transformation. See here for a pretty good explanation. glm::mat4 trans; float factor = 1.0f; float real_vertical = vertical; m_horizontal += horizontal; m_vertical += vertical; while (m_horizontal > TWO_PI) { m_horizontal -= TWO_PI; } while (m_horizontal < -TWO_PI) { m_horizontal += TWO_PI; } if (m_vertical >...

Let's see: g = 9.8 meters/second Take height of your character in pixels and match it to an average man height, say 1.7 meters tall. Then use gravitation formula: y = y0 - g * t^2 / 2 where g is in pixels/second....

javascript,math,physics,linear-algebra

This problem is a lot simpler if you determine the desired acceleration ahead of time, and use that during each refresh. Then the entire code for each frame (excluding the drawing logic and assuming one dimension) just becomes: function frame() { var t = new Date().getTime(), tDelta = t -...

three.js,webgl,physics,physijs

So it turn out the only way to achieve this is to check on each render the velocity of the object and to limit it manually //running right if(character.getLinearVelocity().x > 15){ character.setLinearVelocity({x: 15, y: character.getLinearVelocity().y, z:character.getLinearVelocity().z}); } //running left if(character.getLinearVelocity().x < -15){ character.setLinearVelocity({x: -15, y: character.getLinearVelocity().y, z:character.getLinearVelocity().z}); } ...

The cause is this part: if (vel.X > 0) { player.spritePos.X += vel.X * (float)gameTime.ElapsedGameTime.TotalSeconds; vel.X -= acc.X * (float)gameTime.ElapsedGameTime.TotalSeconds; } if (vel.X < 0) { player.spritePos.X += vel.X * (float)gameTime.ElapsedGameTime.TotalSeconds; vel.X += acc.X * (float)gameTime.ElapsedGameTime.TotalSeconds; } If I rewrite it using the value of acc.X you provided and I...

3d,2d,physics,scenekit,skphysicsbody

Organize your scene so that the 2D plane you want all action to occur in is along two of the coordinate axes. For example, set up your world so that the hero can get around it in x and y, but doesn't need to move in z. Use the...

Except for some shortcuts in notation, subtracting the terms you've already put into A is exactly what you should, and must, do. Here's a slightly shorter version: import sympy # Define constants R1=R3=R5 = 1e3 R2=R4=R6 = 2e3 C1 = 1e-6 C2 = 0.5e-6 x_plus = 3 x_minus = 0...

objective-c,ios8,sprite-kit,physics

Instead of trying to go all real life here why don't you just set your own velocity to damage rankings. First declare a float. Then in the update method add this code: if(myNode.physicsBody.velocity.dy < myFloat) { myFloat = myNode.physicsBody.velocity.dy; } Velocity.dy is vertical movement of a node's physicsBody. All you...

android,rotation,andengine,physics,velocity

The physics connector has a boolean paramter which states the update of body rotation. Unfortunately it was false in my game. I changed it to true and it worked. physicsWorld.registerPhysicsConnector(new PhysicsConnector(levelObject, body, true, false)); to physicsWorld.registerPhysicsConnector(new PhysicsConnector(levelObject, body, true, true)); ...

Some points/suggestions: It seems that you parameterise your Simulink model with K2a (unless I can't see very well from the screenshot), but it's not defined anywhere. You define k2a in your code, but MATLAB is case-sensitive so it's not the same as as K2a. Your Fcn1 block doesn't do anything,...

objective-c,sprite,physics,contact

In all of the code I've seen and from everything I've done, Option 1 seems like the best choice. The reason is that didBeginContact has everything that is needed to handle collisions. Each time it is called, there is a new SKPhysicsContact object, which allows for you to identify everything...

java,algorithm,physics,kinematics

Use BigDecimal to avoid precision loss and incorrect answers due to that. You can break each formula into its own method, and do each part step by step. The more parentheses the harder it will be to read. for example deltaT = tf-ti; vf = vi + a*deltaT; If...

Taking the unit cross product of f*v should give you the required unit torque vector. As far as the magnitude is concerned you will need a time varying torque to get it to stop at the final position otherwise your vector will just continually accelerate. Some sort of triangle function...

The most sensible way to do this, in my opinion, is to build air resistance into the differential equation that governs the system. Air resistance could be approximated by a force proportional to the velocity but in the opposite direction, for example. Then either the equation could be solved in...

So for the future users dealing with the same problem: It is sufficient to divide the current speed by the current RPM actually. By doing so, driving on a particular gear you will get a constant value (+- some small mistake value). It means that if you have 5 gears...

sprite-kit,physics,skphysicsbody

That's exactly the problem you get when rotating a static body, it's not going to act physically correct. For example static bodies have no force, no velocity - if you move or rotate it, it will just be there at the new position and new rotation without pushing any dynamic...

You don't need to perform any trigonometric calculations. Do something like this: ... //Get coords of particle with gravity: double x2 = distantParticle.getCoords('x'); double y2 = distantParticle.getCoords('y'); // Get difference vector double rx = x2 - x1; double ry = y2 - y1; // square of distance double r2 =...

java,math,physics,collision,circle

At the point of collision, momentum, angular momentum and energy are preserved. Set m1, m2 the masses of the disks, p1=(p1x,p1y), p2=(p2x,p2y) the positions of the centers of the disks at collition time, u1, u2 the velocities before and v1,v2 the velocities after collision. Then the conservation laws demand that...

For any physically-reasonable pendulum, your h should be less than 1 (seconds) to model this properly. But you're casting to int which rounds down, so you get h=0 (no time step). Instead, use float: h=float(input("h: ")) q=float(input("Angle: ")) l=float(input("Pendulum length: ")) ...

You're using a velocity check to detect if the character is on the ground. It can take a short while to set it back to zero after colliding with Box2D, so the better way to do it is to use a collision sensor: sprite.grounded = 0 -- Use a number...

Here's how I'd write it: v = float(input('start vlocity m/s: ')) a = float(input('start angle : ')) p = v*math.sin(math.radians(a)) g = 9.81 equ = p*p/(2*g) print(str(equ) + ' M') Check that denominator - shouldn't it be dividing by 2*g?...

java,embedded,accelerometer,physics

Like @John Story stated the best way to handle this is by making an average. Sun spots accelarometers are very unstable and aren't suited for precise velocity prevision. Anyway this is the best code i could make double v=0; double anterior=0; while (true) { double time=System.currentTimeMillis()+200; double currentTime=System.currentTimeMillis(); double offset=0;...

c++,math,physics,game-physics,orbital-mechanics

You're probably looking for Newton's Law of Universal Gravitation. Gm1m2 / r2 = F Once you find F you can just use it in a standard equation of motion: Fyt2 / 2 + vyt + y0 = y Fxt2 / 2 + vxt + x0 = x ...

The right solution is of course to use the relativistic equation for the velocity after "constant acceleration" (which doesn't exist when you get near the speed of light). I suspect you mean "constant apparent acceleration" (what the passengers in the rocket feel). In that case, relativistically, v = c *...

To clear up your understanding, we will fist look at the repulsion being applied. By Default, the Repulsion decay function in Famo.us is a gravity function (an inverse squared distance decay function). Gravity has a decay based on mass and distance. var gridR = new RepulsionForce({ strength: 1, decayFunction :...

A sine is identical to a cosine translated by pi/2 radians. In other words, they only differ by a phase of pi/2. So it doesnt matter which function you use, except that the phase is determined by the initial condition: at t=0, the spring is at y=y0 (normally the speed...

java,math,2d,physics,trigonometry

public void moveForward() { ySpeed += 0.01 * Math.sin(Math.toRadians(targetAngle)); xSpeed += 0.01 * Math.cos(Math.toRadians(targetAngle)); double currentSpeed = Math.sqrt(xTempSpeed * xTempSpeed + yTempSpeed * yTempSpeed); if (currentSpeed > maxSpeed) { //the resulting speed is allways <= maxspeed (normed to that) ySpeed *= maxSpeed/currentSpeed; xSpeed *= maxSpeed/currentSpeed; } hope this is...

c#,algorithm,simulation,physics,numerical-methods

Your model calculates the gravity force between two particles twice: for the first particle the force is based on their original coordinates, and for the second particle it is based on an updated position of the first one. This is a clear violation of the Newton's 3rd law. You must...

javascript,html,css,canvas,physics

Your problem is the collison detection: if (circle.y + circle.radius/2 > canvas.height) { circle.velY*=-Math.sqrt(bounciness); } This just inverts the velocity, but does not adjust the position. Which means that when you drop your balls from certain heights, they can get stuck in the ground - they have entered it by...

javascript,math,vector,simulation,physics

Center-center distance in the touch moment is R12 = R1 + R2 So using cosine theorem: R122 = v'2 + d2 - 2*d*v'*Cos(dv) Solve this quadratic equation against v' and get smaller positive solution value (if 2 cases exist). You can find Cos(dv) through scalar product of vectors d and...

swift,random,sprite-kit,physics

For problem 1: Keep a list of possible places that you can spawn an enemy from. When you create an enemy, remove from the list. When the enemy finishes its action and is destroyed/goes offscreen then replace its starting position on the list. Whenever you roll the dice to generate...

physics,game-physics,unreal-engine4

I think you can just call "Set Target Location and Rotation" on your physics handle.

python,numpy,physics,scientific-computing,differential-equations

I don't have the time to study your solution in detail, but it seems that you are solving the partial differential equation with a forward Euler scheme. This is pretty easy to implement, as you show, but this can become numerical instable if your timestep is too small. Your only...

unity3d,physics,frame-rate,particle-system

This is a known bug in Unity and has been reported previously in their issue tracker. See http://issuetracker.unity3d.com/issues/shuriken-particle-system-module-limit-velocity-over-lifetime-is-fps-dependent

python,arrays,numpy,physics,astronomy

When you are doing physics simulations you should definitely use floats for everything. 0 is an integer constant in Python, and thus np.tile creates integer arrays; use 0.0 as the argument to np.tile to do floating point arrays; or preferably use the np.zeros(N) instead: You can check the datatype of...

This: //Large amplitude pendulum acceleration formula long double dAcceleration = -dMass*dGravity/dLength*sin(myAngle); is incorrect. It should be this: //Large amplitude pendulum acceleration formula long double dAcceleration = -dGravity/dLength*sin(myAngle); That's right, mass doesn't enter into it (unless you start to consider air resistance)....

You are trying to run statements inside a class body. They should be in a method. like this: public class Attempt1{ private void doSomething(){ //example code int a = 1 + 1; while (a < 2) { //do random stuff } } } Right now you have something similar to...

Have you see the tutorials on MSDN? In particular, the Detecting collisions in a 2D HTML5 game seems relevant to your interests. In particular, here's the code used to detect collisions in that tutorial: var circlesOverlap = function(circleA, circleB) { // Public. Returns true if the SVG circles A and...

This type of systems is called differential-agebraic equation. There are standard solvers in netlib, DASSL for example. One has to be careful to use the method that covers the (differentiation-)index of the DAE. Typically, solvers cover index-1 or index-2 systems. If the index is higher, one has to use symbolic...

Jiggling is often caused by the physics time step being too long. If you go to: Edit -> Project Settings -> Time and shorten the fixed timestep interval, you'll be able to get better physics simulation. You can also add friction to the joints to make them a little less...

latex,document,physics,lyx,latex-environment

Stage 1 - Installing IOP Document Files for Texlive (Or Miktex) Windows Users: Check this link for directory location info: http://wiki.lyx.org/Layouts/Iopart The first step is to download the relevant files for IOP documents from here: ftp://ftp.iop.org/pub/journals/ioplatexguidelines.tar.gz If this link has expired, then do a duckduckgo search for "iop latex guidelines"....

physics,angle,orbit,orbital-mechanics

There is not a simple formula as such but there is an algorithm you could program to determine the results. Pentadecagon is also correct in that you need to take into account n*360. You are also right in that you stop one of the planets and work on the difference...