The Daily Click ::. Forums ::. Klik Coding Help ::. Angle Problem
 

Post Reply  Post Oekaki 
 

Posted By Message

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
8th September, 2008 at 19:49:44 -

I need a way to go from MMFs angle system, to an "angle-from-horizontal", and I need it in just one line. I'm sure it should be fairly simple with a few min's and max's etc, but I just can't seem to get my head around it.

It's a little hard to explain, so I drew a diagram;

Image

If anyone can figure it out, I'd be very grateful.

 
n/a

Fifth

Quadruped

Registered
  07/05/2003
Points
  5815

VIP MemberGOTW JULY 2010 WINNER!Kliktober Special Award TagGOTW HALLOWEEN 2011 WINNERPicture Me This Round 51 Winner!
8th September, 2008 at 19:59:29 -

Ooh, I love problems like this!

Try this one:

(90-Abs(90-( <angle value> mod 180)))*(1-(( <angle value> /180)*2))


There's probably a simpler way, but this should work.

 
Go Moon!

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
8th September, 2008 at 20:43:31 -

Thanks a lot for trying, but that doesn't seem to work. It's good for some directions but not others - 45 degrees returns 22.5 for example, when it should return 45.

In case I wasn't clear, I need it to work for all angles 0-360, not just the 8 directions in the diagram.
I'll keep trying, but if anyone else can figure it out in the meantime that'd be great

 
n/a

Fifth

Quadruped

Registered
  07/05/2003
Points
  5815

VIP MemberGOTW JULY 2010 WINNER!Kliktober Special Award TagGOTW HALLOWEEN 2011 WINNERPicture Me This Round 51 Winner!
8th September, 2008 at 20:49:20 -

Mm, it worked fine on my computer...

...but I think I know the culprit.

Try this instead:

(90-Abs(90-( <angle value> mod 180)))*(1-(Int( <angle value> /180)*2))

The only change is the addition of Int (which I should've included in the first place) to make sure it divides properly with floating values.

Image Edited by the Author.

 
Go Moon!

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
8th September, 2008 at 22:03:25 -

You are some kind of mathematical genius! I've got no idea how you came up with that but it works perfectly now. Thanks again

Image Edited by the Author.

 
n/a

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
9th September, 2008 at 02:27:43 -

I do hate how MMF2 handles integers.

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image
   

Post Reply



 



Advertisement

Worth A Click