How do you plot an arc? - Programmers Heaven

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# How do you plot an arc?

Guest
You know those games where you input angle and velocity and shoot at each other? I am trying to make one but can't figure out the math to make the shots arc. I know that it is something to do with trigenometry (cos, sin, and tan) but I need help!

## Comments

• Guest
: You know those games where you input angle and velocity and shoot at each other? I am trying to make one but can't figure out the math to make the shots arc. I know that it is something to do with trigenometry (cos, sin, and tan) but I need help!
:

Well..

Do like this:

' bullet coordinates
dim bulletX as double, bulletY as double
' bullet's speed in x and y direction
dim bSpeedX as double, bSpeedY as double
' angle and power
dim angle as double, power as double

print "Enter angle: "
input angle

print "Power : "
input power

bSpeedX = cos(angle * 3.141592 / 180) * power
bSpeedY = sin(angle * 3.141592 / 180) * power

' move bullet
bulletX = bulletX + bSpeedX
bulletY = bulletY + bSpeedY

That's it..

Now if you enter angle of 0(zero) and power of 10,
bullet will fly to the right 10 pixels a time.
cos and sin use radians, so you must convert angle from
degrees to radians (angle * PI / 180)

Hope that helped..

Sign In or Register to comment.