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 5966981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:52:38+00:00 2026-05-22T19:52:38+00:00

I am trying to throw a ball in an arc, either an arc going

  • 0

I am trying to throw a ball in an arc, either an arc going left or right.

Here is my code:

var gravity = 2;
this.velocity.y += gravity;
                _angle = 5;
                var theta:Number;
                switch(_direction) {
                    case "left":
                        theta = _angle * Math.PI/180;
                        this.velocity.x = Math.cos(theta) - Math.sin(theta);
                    break;

                    case "right":
                        theta = _angle * Math.PI/180;
                        this.velocity.x = Math.cos(theta) - Math.sin(theta)
                    break;
                }

                this.x += this.velocity.x;
                this.y += this.velocity.y;

It doesn’t really look like the ball is “arcing” at all, it seems to be more of a diagonal line?

  • 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-22T19:52:38+00:00Added an answer on May 22, 2026 at 7:52 pm

    When throwing you have two components.

    1. A vertical acceleration due to the magics of gravity. This will be ay.

    2. A horizontal component: Without air friction this is a constant velocity.

    Let’s say you throw the ball and at the moment of leaving your hand it has a velocity v0 = (v0x, v0y) and is at position p0. Then v0x will be constant for all time.

    The speed of the ball at time t would be v(t) = (v0x, v0y + t * ay)

    For each tick of your animation, add deltat * v(t) to the current position of the ball and you should be set.

    Everytime the ball bounces, you should mirror its velocity vector on the surface it bounced and substract a certain percentage of its total energy (Ekin + Epot, although Epot will be 0 if it is on the ground and the gound is zero potential), in order to get a logarithmic bouncing.

    If you want air friction too, just substract a certain small percentage of the total energy with every animation tick.

    Here some code, not in ActionScript, but I hope readable. (The parameters to the ctor are both Vector2d; clone() used implicitly but you can guess what it does):

    class Vector2d:
        def __init__ (x, y):
            self.x = x
            self.y = y
    
        def add (other):
            self.x += other.x
            self.y += other.y
    
        def mulScalar (scalar):
            self.x *= scalar
            self.y *= scalar
    
        def mulVector (vector) # NOT the cross product
            self.x *= vector.x
            self.y *= vector.y
    
    class BouncingBall:
        AGRAV = ? #gravitational acceleration (mg)
        DELTAT = ? #time between ticks
        ELASTICITY = ? Elasticity of ball/floor
    
        def __init__ (self, pos, v):
            self.pos = pos
            self.v = v
    
        def tick (self):
            deltapos = self.v.clone ()
            deltapos.mulScalar (DELTAT)
            self.pos.add (deltapos)
            if self.pos.y <= 0: #bounce
                self.pos.y = 0 #adjust ball to ground, you need to choose DELTAT small enough so nobody notices
                self.v.mulVector (1, -1) #mirror on floor
                self.v.mulScalar (ELASTICITY)
            self.v.add (0, AGRAV * DELTAT)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying the camera preview This is my code and it doesn't throw any
I'm trying to make this code generic: public final Object unwrap(Class arg0) { throw
I'm trying to throw an exception in my code like this: throw RuntimeException(msg); But
this code throw exception while i am trying to update value ,first value only
Why do I get an InvalidCastException when trying to do this? throw (ArgumentNullException)(new Exception(errormessage,
So I am trying to throw in a little catchy code to the Product
I'm trying to write some code that catches a particular exception and throw a
I have some code where i am trying to throw a custom exception in
I trying to get page from this url: YandexMarket but WebClient and httpWebRequest throw
I'm trying the following code: Try ' DOESN'T WORK Throw 2 ' How do

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.