Movement Of Point Towards Other Point

taj134

Newcomer
Joined
Feb 21, 2003
Messages
2
Ive been trying to write a Flocking Algorithm in VB.net but ive been having problems making the points move correctly.
Im having serious problems making something move towards something else correctly. I know the Math.Functions are in Radians, thats ok, but i cant work out the correct procedures for the angle between the points to be calulated.

(0,0) ---------------------------------------------(100,0)
| x (10,5)
|
|
|
|
|
|
|
|
| . . . . . . . . . . . . . . . . . . . . . . y(75,80)
|
|
|
|
|
(0,100)

0 Radians points towards the left, (took lots of experimentation to work that out, depressing really)
And to find my angle i use the Soh-Cah-Toa thing, therefore

ATan((80-5)/(75-10)) should be the angle i need.
but it only works correctly in the situation above. If i want the angle from y to x i get stupid results, after changin the Opp and Adj values.

Please help, its driving me mad.

I started programming it to remind me howto do vanilla VB after doing ASP for so long and as im starting Compu Science course in Uni. but its all gone mad.

:(

Toby

Edit: Added Dots to put the Y in correct place after the HTML removes the "white space"
 
No problems anymore. After spending about 12 hours working on the problem, i split the class up into two programs to test the methods, then got each bit working properly, put it back into my main program and Voila, working program. I even discovered how to use the GDI+ which is useful.
Im now going to work on some useful flocking algorithms to go with the movement. Hurrah

Toby

p.s. If anyone wants the code that worked, PM me and i'll try and get it off my laptop onto the Uni computer system
 
Back
Top