physics

Implementation of Runge Kutta Fourth Order in c++ [closed]

爷,独闯天下 提交于 2019-12-14 03:31:56
问题 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 4 years ago . So I should start by saying that this is my first attempt a executable script, and my first ever c++ script. Bearing this in my mind my problem is as follows. I'm attempting to create a script which shall integrate projectile motion with the use of the Fourth Order Runge Kutta method. Currently my script is

Re: Space physics for missiles, spaceships

Deadly 提交于 2019-12-13 17:36:56
问题 In this rather useful CodeProject article, an enterprising and very helpful person has done the math needed for a newtonian missile to hit a newtonian target (it also works for matching course and speed between spaceships, with a bit of fiddling of inputs). One of the things I've written with this in the past is a battle between up to hundreds of spaceships (blocks), firing missiles (blocks) at each other. Quite neat. However, it only works for purely newtonian craft and, as anyone who's paid

Bouncing a ball off a wall with arbitrary angle?

吃可爱长大的小学妹 提交于 2019-12-13 12:12:11
问题 I'm trying to let the user draw a paddle that they can then use to hit a ball. However, I cannot seem to get the ball to bounce correctly because the x and y components of the ball's velocity are not lined up with the wall. How can I get around this? I tried the advice given by Gareth Rees here, but apparently I don't know enough about vectors to be able to follow it. For example, I don't know what exactly you store in a vector - I know it's a value with direction, but do you store the 2

Find destination position of ball

跟風遠走 提交于 2019-12-13 10:29:31
问题 How to move the ball dependent on touch angle and make the ball reflect if it touches the wall? CGFloat diffX = ballImg.position.x - tchLoc.x; CGFloat diffY = ballImg.position.y - tchLoc.y; CGFloat angleRadian = atan2f(diffY, diffX); float angleDegrees=CC_RADIANS_TO_DEGREES(angleRadian); 回答1: I am considering that you have taken your ball as a sprite. so in touchesBegan you will get the touch location and then you can use that location points in CCMoveTo action to move your ball which is a

Best way to drag Sprites that are attached via SKPhysicsJoints?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 03:59:20
问题 I'm having trouble moving sprites that are attached via an SKPhysicsJoint. I have a touchesMoved method that looks like this: - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint positionInScene = [touch locationInNode:self]; CGPoint previousPosition = [touch previousLocationInNode:self]; CGPoint translation = CGPointMake(positionInScene.x - previousPosition.x, positionInScene.y - previousPosition.y); CGPoint newPosition =

Box2D via libGDX: How to create one MouseJoint per body for separate Android touches?

落爺英雄遲暮 提交于 2019-12-13 03:59:05
问题 What's up everyone, Thanks for your time. I am making a Pong clone, and I want to restrict Box2D to two MouseJoints maximum; one MouseJoint maximum per paddle. The MouseJoints should be created only if one of the user's two touches lands within either of the two paddle's boundaries. I am getting a weird result with my code. If my first touch lands within the left paddle and my second touch lands outside of either paddle, a second MouseJoint is created on the left paddle (see attached image).

how do i have one physics body negate the collision of another.

不想你离开。 提交于 2019-12-13 01:39:13
问题 i have two images on the screen that overlap called A and B. i have a third image called C that the user is able to move around the screen. the bigger one (A) of the two resets the C to the spawn point on collide. i need to know how to make it so that C can walk over image B and not be reset to the spawn point. as in image B overlaps image A and negates the collision function. here is the code: --Hides status bar from top of page display.setStatusBar( display.HiddenStatusBar ) --Set a test

AI of spaceship's propulsion: control the force to land a ship at x=0 and v=0

亡梦爱人 提交于 2019-12-12 13:43:55
问题 I have to code AI to control many propulsion jets for a spaceship in a game. For simplicity :- Let the space be 1D. Spaceship is a point and there is only 1 jet. Rule and problem Let x , v and a are position, velocity, acceleration of the spaceship. Let F be the force of jet that apply to the ship. I know mass m of the spaceship, let's say m =1. Here is a summary :- acceleration = F/m; v = vOld + acceleration*timestep; x = xOld + v*timestep; The objective is to land the ship on a certain

Speedup MSD calculation in Python

萝らか妹 提交于 2019-12-12 08:54:10
问题 It's a call to the community to see if anyone has an idea to improve the speed of this MSD calculation implementation. It is largely based on the implementation from this blog post : http://damcb.com/mean-square-disp.html For now the current implementation takes about 9s for a 2D trajectory of 5 000 points. It's really way too much if you need to compute a lot of trajectories... I didn't try to parallelize it (with multiprocess or joblib ) but I have the feeling that creating new processes

Determining Resting contact between sphere and plane when using external forces

有些话、适合烂在心里 提交于 2019-12-12 07:49:39
问题 This question has one major question, and one minor question. I believe I am right in either question from my research, but not both. For my physics loop, the first thing I do is apply a gravitational force to my TotalForce for a rigid body object. I then check for collisions using my TotalForce and my Velocity . My TotalForce is reset to (0, 0, 0) after every physics loop, although I will keep my velocity . I am familiar with doing a collision check between a moving sphere and a static plane