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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:29:09+00:00 2026-05-27T01:29:09+00:00

xVel = velocity * Math.cos(angle); yVel = velocity * Math.sin(angle); This is what I

  • 0
xVel = velocity * Math.cos(angle);
yVel = velocity * Math.sin(angle);

This is what I use to convert a single initial velocity to x and y velocity, using the angle input by the user. Occasionally the xVel will be negative. I was wondering if using an absolute value Math function would be fine or would it mathematically skew my results.

This is what I was thinking for that:

xVel = velocity * Math.abs(Math.cos(angle));

Programming in Java BTW, even though that doesn’t really matter in this case.

EDIT: Due to a lack of some important information I will add some revisions.

Occasionally I will enter a value for an angle that is in the positive quadrant (i.e. 15°) and still get a negative xVel.

Also this program is assuming that the angle is being counted up from the x axis in a counter clockwise fashion.

  • 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-27T01:29:10+00:00Added an answer on May 27, 2026 at 1:29 am

    You are getting a negative x velocity for a 15 degree angle because Math.cos and Math.sin accept the angle in radians and not degrees.

    You must first convert your angle in degrees to an angle in radians like this:

    xVel = velocity * Math.cos(angle * Math.PI / 180.0);
    yVel = velocity * Math.sin(angle * Math.PI / 180.0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a combination of SDL and OpenGL in a sort of crash course
I have got a ball which bounces of walls. This bounce is simple, i
I have created a class that extends JLabel to use as my object moving
I am making a Javascript game with the canvas tag, and I am using
First time using MPI outside some simple practice apps, and something's not going right.
I'm writing a pong game and I have a ball class that has velocity
I've got the following code, think simple shooter in c++: // world.hpp //---------- class
I'm trying to add 10 levels and 1 per page, which is 10 pages.
I'm modeling a vector field in flash and spawning a mess of particles to
I have a shader that draws particles with solid colors. I would like to

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.