Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 980739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:25:57+00:00 2026-05-16T04:25:57+00:00

This is a pure physic question but i don’t know why it doesn’t work….i

  • 0

This is a pure physic question but i don’t know why it doesn’t work….i have a moving object.i get the value of vcos(theta) and vsin(theta)…from this i calculate the velocity and angle of motion…..also i know another point (x,y) and want to direct the object to this point.I think i need to apply a certain force(force must have X and Y axis value)to direct the object towards the point….so to get the amount of force required i just follow
the formula:

fX=V2cos(theta2)-V1cos(theta1)
fY=V2sin(theta2)-V1sin(theta1)

no matter what ever the syntex are given bellow(i give it for those people know objective c)………my equation doesn’t work…..can anyone help……

    if (acceleration.x>1.5 || acceleration.y>1.5) {

            shakeCounter++;
            [_label setString:[NSString stringWithFormat:@"%d",shakeCounter]];  


        //get the velocity of moving object.......................  
        b2Vec2 mVelik = ballBody->GetLinearVelocityFromLocalPoint(localPoint);


        float angleOfCurrentDirectionOfMotion;
        float angleOfDesiredDirectionOfMotion;
         //calculate first velocity
        float V1=sqrt(pow(mVelik.x, 2)+pow(mVelik.y, 2));
        //calculate second velocity
        float V2=V1+factor;
        //calculate current  angle
        angleOfCurrentDirectionOfMotion=atan(mVelik.y/mVelik.x);
         //calculate desired angle
        angleOfDesiredDirectionOfMotion=atan(acceleration.y/acceleration.x);
///calculate FX and FY
        float X=V2*cos(angleOfDesiredDirectionOfMotion)-V1*cos(angleOfCurrentDirectionOfMotion);
        float Y=V2*sin(angleOfDesiredDirectionOfMotion)-V1*sin(angleOfCurrentDirectionOfMotion);

        b2Vec2 force = b2Vec2(X,Y);

 ///apply Force to change direction....   
        ballBody->ApplyForce(force, ballBody->GetPosition());

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T04:25:58+00:00Added an answer on May 16, 2026 at 4:25 am

    I do not have box2d to experiment with, but I will assume it works as it should.

    You cannot disregard the mass of the object; the greater the mass, the less the effect of a force.

    Your calculation of X and Y seems correct (although overcomplicated). You can change the motion with an impulse applied to the center of mass::

    b2Vec2 impulse = b2Vec2(X,Y) * ballBody->GetMass() ;
    ballBody->ApplyLinearImpulse(impulse, ballBody->GetLocalCenter());
    

    If you really want to use a force and not an impulse, there is a range of solutions. Generally you can choose the magnitude of the force first, then calculate the direction, or the other way around. I can give you the equations (and maybe code) but it will not make any sense without an understanding of basic physics.

    EDIT:
    All right, the equation of one-dimensional motion is
    x = x0 + V0t + at2/2, so WLOG assume ax = 1 in the direction of the target point, and solve for time (the time when the x of the ball will equal the x of the target point). Then put that time into the equation for y and solve for ay, and you’re done.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.