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

  • Home
  • SEARCH
  • 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 6705985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:28:01+00:00 2026-05-26T07:28:01+00:00

I am trying to implement a projectile motion for my app.To begin with I

  • 0

I am trying to implement a projectile motion for my app.To begin with I am trying to plot the points on the projectile.I am assuming my initial velocity to be 5m/s.

I tried to calculate my initial velocity based on projection angle for x and y direction respectively.But I am getting it’s vale us NaN(Not a number).

Also I am trying to plot first 10 points on the path of trajectory but am getting NaN for them also.As the time returned by now is in millisecond I am converting it into seconds.

Please suggest where I went wrong.

public void drawProjectile(double angle)
 {
     Log.w(this.getClass().getName(),"drawProjectile called");
     mUx = mUi*Math.acos(angle);
     mUy = mUi*Math.asin(angle);


     Log.d(this.getClass().getName(), "Value of mUx: " + Double.toString(mUx));
     Log.d(this.getClass().getName(), "Value of mUy: " + Double.toString(mUy));
     for(int i = 1;i<=10;i++)
     {
     Log.w(this.getClass().getName(),"In plotting points loop");
     long now = System.currentTimeMillis();
     mX1=(float) (mUx*now)/1000;
     mY1 = (float) (mUy*now/1000+(mGravity/2)*now*now/1000000);

     Log.d(this.getClass().getName(), "Value of mX1: " + Float.toString(mX1));
     Log.d(this.getClass().getName(), "Value of mY1: " + Float.toString(mY1));
     mCanvas.drawPoint(mX1, mY1, mPaint);
     }
  • 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-26T07:28:02+00:00Added an answer on May 26, 2026 at 7:28 am

    I think you want Math.cos(angle) and Math.sin(angle), not Math.acos(angle) or Math.asin(angle). Also, make sure that angle is in radians, not degrees.

    EDIT: Regarding the “exponential values,” my guess is that you shouldn’t be using the current system time in your calculations. (That is the number of milliseconds since the start of January 1, 1970; hardly a time relevant to your problem.) You should be using the elapsed time from when your program started (long start = System.currentTimeMillis(); before the loop, then subtract start from now inside the loop), or (perhaps better) a simulated time between points. Something like this:

    float now = 0f;
    for(int i = 1; i <= 10; i++) {
        Log.w(this.getClass().getName(),"In plotting points loop");
        mX1 = mUx*now;
        mY1 = mUy*now + (mGravity/2)*now*now;
    
        Log.d(this.getClass().getName(), "Value of mX1: " + mX1);
        Log.d(this.getClass().getName(), "Value of mY1: " + mY1);
        mCanvas.drawPoint(mX1, mY1, mPaint);
        now += 1f; // or whatever time increment you want
     }
    

    If you need to use actual elapsed time, then this loop won’t do it, because the time for executing the 10 iterations won’t amount to any perceptible change in system time.

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

Sidebar

Related Questions

Trying to implement a UITableView of names similar to the built-in Contacts iPhone app
I am trying to implement a perspective projection. For example, I have a square
Just trying to implement mobFox into my app, but having trouble to make it
All I am currently trying implement something along the lines of dim l_stuff as
trying to implement a dialog-box style behaviour using a separate div section with all
Trying to implement a rating system of users and postings. What is the best
Am trying to implement a generic way for reading sections from a config file.
While trying to implement an MVC file upload example on Scott Hanselman's blog. I
im trying to implement some behaviors when a mapview element scrolls... by coding a
when trying to implement an Aspect, that is responsible for catching and logging a

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.