c - Change direction of a moving object....(pure physic question) -
This is a pure physical question, but I do not know why this does not work ... I have a moving object .i to get the value of vcos (theta) and versatile (theta) ... from this I calculate the angle of velocity and speed ... I also know another point (x, y) and the object At this point you want to direct. I think that in order to direct the object, I need to implement a certain force (should be the value of X and Y axis in force). So to get the amount of force needed, I follow:
fx = v2cos (theta2) -V1cos (theta1) fy = v2sin (theta2) -v1 sin (theta1)
There's nothing that ever Also syntex has been given (i aim to give it to those people) ......... my equation does not work ..... any help Can ... ......
if acceleration.y & gt; 1.5) {shakeCounter ++; [_label setstring: [NSString stringWithFormat: @ "% d", Shake Cropper]]; // Get the Velocity of Hill Object ....................... b2Vec2 mVelik = ballBody- & gt; GetLinearVelocityFromLocalPoint (localPoint); Float angleoffentant directionoffmission; Float anglefdisardirdirectionoffment; // First velocity float v1 = sqrt (pow (mVelik.x, 2) + pau (mVelik.y, 2) calculation; // second velocity float V2 = V1 + factor calculation; // Calculate the current angleAffondentationFormation = come (MVL.I./MVL.X); // Calculate the desired angleOfDisdirectDirectionofferation = come (acceleration.A. / acceleration.x); /// Fx and FY Float X = V2 * Cos (Angleoff Dedicated Directionofferation) -V1 * cos (angle off content directionoffment); Float Y = V2 * sin (angleoff designated expressionofferation) -V1 * sin (angleoff content directionoffment); B2VK2 force = B2 vc2 (x, y); // Apply force to change direction .... ballBody-> Force applied (force, ballboard-> gt; GetPosition ()); }
I do not have box2d to experiment, but I think it It works should be
You can not ignore the mass of the object; The greater the mass, the effect of one power is less.
Your calculations of X and Y look correct (though greater than). You apply to the center :: b2Vec2 impulse speed = B2VK2 (x, y) * ballBody-> gt; Can change speed with GetMass (); BallBody-> ApplyEyller impulse (Impulse, Ballbodie-> Gatlocell Center ());
If you really want to use a power and there is no impulse, then there is a series of solutions. Usually you can choose the magnitude of force first, then calculate the direction or on the other side. I can give you the equation (and maybe code), but without understanding the basic physics it will not make sense.
Edit:
OK, the equation is one-dimensional speed x = x 0 + V 0 T 2 is on, so the value of the WLOG returns x = 1 in the direction of the target point, and the solution for time (time when the x of the ball is X Will be equal). Then put that time in the equation for y and solve for y , and you have done it.
Comments
Post a Comment