The Daily Click ::. Forums ::. Klik Coding Help ::. Meh. Trig.
 

Post Reply  Post Oekaki 
 

Posted By Message

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
28th September, 2006 at 18:27:56 -

I'm having some trouble getting an 'angle between two points' expression to work.

The expression I'm using right now is:

ATan((Y( "BOUNCE" )+0.0-Y( "Active" )+0.0)/(X( "BOUNCE" )+0.0-X( "Active" )+0.0))

This is being done in MMF2, demo version (hence why I can't just use an extension to do it for me).

For some reason, it works from 0 to 90 degrees, and then starts going into minus figures... and then back into positives again. And then back into negatives.

The result is that directly up left from the object is 45 degrees...
...But directly DOWN LEFT is also 45 degrees.

The help file says that ATAN uses degrees, just like Sin and Cos, but is there a problem with ATan? Am I just doing it wrong?

If ATan is retarded, can I use an alternative expression to get the angle?

 
191 / 9999 * 7 + 191 * 7

Ski

TDC is my stress ball

Registered
  13/03/2005
Points
  10130

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!KlikCast HelperVIP MemberWii OwnerStrawberryPicture Me This Round 28 Winner!PS3 OwnerI am an April Fool
Candy Cane
28th September, 2006 at 18:47:44 -

Even I cant help you on that one

 
n/a

Joe.H

Evil Faker

Registered
  19/08/2002
Points
  3305
28th September, 2006 at 20:32:52 -

No, it's right. It just means the angle falls in a different quadrant.

If you get the angle as as - number, just add 180 to the angle and you should get another value which will give the same answer. However, if may not neccesarily give you the angle you want. The positive value of the negative value will also return the same answer. There are several different answers you could get for the correct angle though, MMF just returns one of them. If it's < 0, just keep adding 180 until you get 0 <= angle <= 360, and try and make a system which chooses the correct one from a possible value. (usually it would be the first one it comes to that's 0 < a < 360)

Maybe. I'm tired atm so my maths brain isn't working ^^

 
My signature is never too big!!!

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
29th September, 2006 at 08:11:59 -

...so how exactly do I find the angle between two points?

 
191 / 9999 * 7 + 191 * 7

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
29th September, 2006 at 08:22:49 -

I think podunkian made an extension that does that for you.

 
.

..:.Phox.:..



Registered
  18/02/2005
Points
  646

VIP MemberHero of TimeI like Aliens!Cardboard BoxAttention Getter
29th September, 2006 at 12:50:14 -

yep

 
Profile edited as it messed the layout of the site up.

markno2



Registered
  06/06/2006
Points
  865

Game of the Week WinnerVIP MemberPicture Me This Round 30 Winner!Weekly Picture Me This Round 39 Winner!Kliktober Special Award Tag
29th September, 2006 at 13:50:30 -

.....You lost me at hello.

 
Discarded pizza boxes are an indispensable source of cheese.

Werbad



Registered
  18/09/2002
Points
  235
3rd October, 2006 at 06:58:04 -

If i remember correctly, ATan will only return a number that is -90 -> 90, so you'll need to do extra chacks to find the correct angle

 
n/a

Alex Wells



Registered
  23/06/2005
Points
  28

KlikCast Star
3rd October, 2006 at 13:50:19 -

Yeah... dude use the advanced direction calculator

 
Battalion/Eden Online--
In internal testing

Reno



Registered
  11/01/2005
Points
  906
3rd October, 2006 at 16:16:44 -

wow I hesitated when clicking this link, but yet I seemed to have eventually clicked this link :|

I hate trig.

 
Reborn Again

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
3rd October, 2006 at 16:56:48 -

I'm too stupid for trig, but I can still make 360 deg movement engines, yay!

 
n/a
   

Post Reply



 



Advertisement

Worth A Click