Click here to Skip to main content
15,894,405 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralInfo on MS Intermediate Language Pin
Aamir Mughal15-Jan-04 2:40
Aamir Mughal15-Jan-04 2:40 
GeneralRe: Info on MS Intermediate Language Pin
Mike Dimmick15-Jan-04 4:05
Mike Dimmick15-Jan-04 4:05 
GeneralSOAP and serialization Pin
ProffK14-Jan-04 23:10
ProffK14-Jan-04 23:10 
GeneralWord-addin Pin
klawipo14-Jan-04 6:29
klawipo14-Jan-04 6:29 
GeneralAdvanced Collision Detection with GDI+ Pin
david@mindplay.com13-Jan-04 9:34
david@mindplay.com13-Jan-04 9:34 
GeneralRe: Advanced Collision Detection with GDI+ Pin
pwinant14-Jan-04 10:29
pwinant14-Jan-04 10:29 
GeneralRe: Advanced Collision Detection with GDI+ Pin
david@mindplay.com15-Jan-04 9:05
david@mindplay.com15-Jan-04 9:05 
GeneralRe: Advanced Collision Detection with GDI+ Pin
pwinant15-Jan-04 13:03
pwinant15-Jan-04 13:03 
I was afraid you'd ask that. Poke tongue | ;-P You seem to be in a 2D world with a bearing (presumably in degrees) and a velocity, so my answer will be based off that assumption.

A 2D vector can be thought of as a line going from the origin of a cartesian coordinate system <0,0> to the point <x,y>, so the vector can be represented with 2 scalar values x and y.

To calculate the length of a vector we simply calculate the distance between the origin and the point at <x,y> :

length = sqrt( (x-0)*(x-0) + (y-0)*(y-0) )
= sqrt(x*x + y*y)

You can think of the "length" of the velocity vector as the actual velocity of the ship, and the coordinates as the bearing. So the velocity vector contains both the direction and the velocity. If, for example, the ship is traveling at a 45 degree angle, the velocity in vector notation might be <1, 1> or <2, 2>, or <3, 3>, etc., depending on how fast it's going. If the vector is <1, 1> it means the length (i.e., velocity) is sqrt(2), if the vector is <2, 2>, the velocity is sqrt(8), etc.

In your case you need to take the sine of the bearing as the X coordinate for the velocity vector, and the cosine of the bearing becomes the Y coordinate for the vector. Then you scale that vector by your velocity amount by multiplying the x and y component of the vector by that amount.

Rather than get into vector dot products and cross products and other scary stuff, I think it would be better if I just refer you to another document that I think does what you're looking for.

http://www.gamedev.net/reference/articles/article1019.asp
This shows an implementation of 2D vectors and also a function for computing the angle to adjust a ball striking a pool table edge, which sound like the kind of thing you're doing. Look for the function "CBall::HitBoundary".

If you want to read up on 2D vector math, etc. there's a million places you can go on the web. Here's a page that explains unit vectors and vector dot products: http://www.geocities.com/SiliconValley/2151/math2d.html

Good luck!

Phil
GeneralRe: Advanced Collision Detection with GDI+ Pin
david@mindplay.com15-Jan-04 13:37
david@mindplay.com15-Jan-04 13:37 
GeneralRe: Advanced Collision Detection with GDI+ Pin
david@mindplay.com17-Jan-04 14:00
david@mindplay.com17-Jan-04 14:00 
GeneralLaunching an outside app with .NET Pin
bneacetp13-Jan-04 3:18
bneacetp13-Jan-04 3:18 
GeneralRe: Launching an outside app with .NET Pin
Niels Penneman13-Jan-04 5:45
Niels Penneman13-Jan-04 5:45 
GeneralRe: Launching an outside app with .NET Pin
bneacetp13-Jan-04 7:54
bneacetp13-Jan-04 7:54 
Questionhow to get install path Pin
yu-yu12-Jan-04 20:53
yu-yu12-Jan-04 20:53 
AnswerRe: how to get install path Pin
Heath Stewart14-Jan-04 9:41
protectorHeath Stewart14-Jan-04 9:41 
GeneralRe: how to get install path Pin
yu-yu14-Jan-04 15:37
yu-yu14-Jan-04 15:37 
QuestionHow do you access the scrollbar of a panel? Pin
pwinant12-Jan-04 15:49
pwinant12-Jan-04 15:49 
AnswerRe: How do you access the scrollbar of a panel? Pin
Heath Stewart14-Jan-04 9:30
protectorHeath Stewart14-Jan-04 9:30 
GeneralRe: How do you access the scrollbar of a panel? Pin
pwinant14-Jan-04 10:04
pwinant14-Jan-04 10:04 
GeneralMultithread synchronisation in VB.net Pin
Paul Farry11-Jan-04 20:46
professionalPaul Farry11-Jan-04 20:46 
GeneralSuspend/resume Pin
Anonymous10-Jan-04 17:31
Anonymous10-Jan-04 17:31 
GeneralProblem: difference in behavior between ASP.NET &amp; .NET EXE calling SOAP::Lite web service Pin
claughlin9-Jan-04 6:07
claughlin9-Jan-04 6:07 
Generalabout how to use package installer Pin
Anonymous8-Jan-04 22:31
Anonymous8-Jan-04 22:31 
GeneralRe: about how to use package installer Pin
UB9-Jan-04 5:39
UB9-Jan-04 5:39 
GeneralRe: about how to use package installer Pin
yu-yu12-Jan-04 20:57
yu-yu12-Jan-04 20:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.