Just a small snippet for those who don't know how to use radians. You don't have to give me credits for anything just use it as you wish.
function DegtoRad( degree ){
return degree * ( PI/ 180 );
}
function RadtoDeg( radian ){
return radian * ( 180 / PI );
}
What's the point of declaring a variable inside a function only to use it once :-\ You're just wasting instructions in the Squirrel Virtual Machine. Not to mention the PI is a constant built into the language.
function DegtoRad( degree ){
return degree * ( PI / 180 );
}
function RadtoDeg( radian ){
return radian * ( 180 / PI );
}
Updated. It's been awhile since I last coded Squirrel extensively so I may have forgotten several things. Thanks for pointing it out though.
const ToRadian = 0.0174533;
const ToDegrees = 57.2958;
function DegtoRad( degree ) return degree * ToRadian;
function RadtoDeg( radian ) return radian * ToDegrees;
* Gudio wins!
Quote from: Gudio on Jan 24, 2015, 01:35 PMconst ToRadian = 0.0174533;
const ToDegrees = 57.2958;
function DegtoRad( degree ) return degree * ToRadian;
function RadtoDeg( radian ) return radian * ToDegrees;
* Gudio wins!
function DegtoRad( degree ) return degree * 0.0174533;
function RadtoDeg( radian ) return radian * 57.2958;
Easier to push a literal value directly than a reference to a value that must be dereferenced later :D Though it's a waste of time.