The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

C++, Degrees and Space Mines by really-joel2007-08-08 07:24:21
  Look up the Unit Circle by sazzer 2007-08-08 07:39:59
The Wikipedia article doesn't seem too bad about it...

If I understand what you're after correctly, you have a starting position and an angle that the bullet is going, and you want to get the position of the bullet after time t, when it's travelling at a speed s.

Firstly I'd work in velocity and not speed, since velocity is a vector itself and can just be added to the current location easily. The new location = The old location + (The velocity * the time difference). This assumes that the location can be described as [X, Y] and the velocity as [dX, dY] (Possibly with Z and dZ if necessary, which it's not here). This means simply that X2 = X + (dX * t) and Y2 = Y + (dY * t).

To get the velocity from the speed and the angle is, as you said, a case of using sin/cos. In this case, dX = s * cos(a), where a is the angle and s is the speed. dY = s * sin(a) for the same values.
[ Reply ]
    If I understood correctly.. by really-joel2007-08-08 07:59:20
      I'll point out that by sgrunt2007-08-08 08:09:49
        It does! by really-joel2007-08-08 08:13:04
          Aha: by sgrunt2007-08-08 08:13:59
            Wehoo by really-joel2007-08-08 08:21:01
          degrees vs rads by ExO_DsR2007-08-08 08:18:04
      C++ nitpick by Michiel2007-08-08 08:18:48
        =) by really-joel2007-08-08 08:22:15
        Also by Orky2007-08-09 07:22:59
          I misinterpreted by really-joel2007-08-12 06:55:33

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)