View Single Post
  #1  
Old 05-08-2008, 03:16 AM
Robin Robin is offline
The secret of NIMH
Robin's Avatar
Join Date: Apr 2005
Location: Wales, UK
Posts: 515
Robin will become famous soon enough
Send a message via AIM to Robin
Useful functions

Some general useful functions in GS2 (Some of them are for compatibility with JS/PHP/etc others are just good)
PHP Code:
function rand() {
  return new 
MRandomLCG().randFloat();
}
function 
tan(x) {
  return 
sin(x)/cos(x);
}
function 
atan2(y,x) {
  return 
x<>0?x>0?atan(y/x):atan(y/x)-radian(180):y>0?radian(90):radian(-90);
}
function 
atan(number) {
  return 
arctan(number);
}
function 
floor(number) {
  return 
int(number);
}
function 
ceil(number) {
  return 
int(number) < number number number;
}
function 
radian(degree) {
    return (
degree 0.0174532925);

function 
degree(radian) {
    return (
radian 57.2957795);

function 
square(n) {
    return (
n);

function 
norm(angle) {
    return (
angle 6.283185 floor((angle pi) / 6.283185));

function 
tile(pixel) {
    return (
pixel 16);

function 
pixel(tile) {
    return (
tile 16);

Enjoy
__________________


Last edited by Robin; 05-08-2008 at 04:53 AM.. Reason: Updated to reflect awesomeness.
Reply With Quote