The Official Blog of Patcoola

Im just a dude watching over my parents,
and trying to make cartoons and video games from home.

Script: Degrees To Four Way Direction [JS]

Important!

Dear visitors,

This blog and the Tigarus.com network will be changing our website software in May (2024). There will be some down time and there will be a change to the webpage addresses.

We will also be removing the Anime blogs. The Rocksmith Songs website will be unavailable of a few weeks or months while I move the database to the new software.

At the moment we are running on Wordpress, the new software is an in-house project which is 57 times faster. It will also provide more freedom for development.

Thank you for understanding.

, By Patcoola

Script Title: degToFourDir
Programming Language: Java Script
Date Completed: 2012/09/02

Purpose: To determine the direction something is from degrees. Returns a number between 0-3.

Advertisement

Donate Now!

This might not be the best time, but making a blog is not easy. Would you consider donating?


Description: Determine the direction something is based on a four way system of direction from degrees. Determines the direction using four directions, returns a number ( 0,1,2,3 ), returns NaN (Not a Number) if the degrees argument is not a number, is a value greater than 360 or is a value lesser than -360.

Returned Values:

0 – Top
1 – Right
2 – Bottom
3 – Left
NaN – If the degrees_n argument is not valid

Method:

degToFourDir ( degrees_n ); // Returns a number

Arguments: degrees_n, accepts a number between -360 to 360.

Example Usage:

degToFourDir ( 180 ); // Returns 2

degToFourDir ( -180 ); // Returns 2

degToFourDir ( 760 ); // Returns NaN

 

Advertisement

Donate Now!

I don't always use the women's bathroom, but when I do, you can bet it really smells. If you like my blog, please consider donating.


 

Post Meta

Share Post

 

Comments: Write Comment

Be the first to write a comment.


Leave a Comment


All comments are reviewed before publishing. Comments must be related to the page topic, must not be spam, and must comply with the criminal code of Canada.

 
26.511362 milliseconds