• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

bj_DEGTORAD vs. bj_RADTODEG

Status
Not open for further replies.
Level 2
Joined
Feb 22, 2012
Messages
13
bj_DEGTORAD is 0.017453292 so I hear... and is this true?
Also... what is bj_RADTODEG?
friend told me to not use that cuz its for gui... users so just wondering please be accurate gonna use it on a slide trigger..
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
So what is it? Not really good with math thats why I ask in the first place.

its something what help to u for working with more understandable numbers because sin(x),cos(x) => x between 0-1 so without them a bit harder to users make something example with 45 face angle

until now kinda easy coz u use normal grades (0-360) and * with degtograd,so dont need to use more confuseable small values like 0.213 etc
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
u said u are bad in math :p

anyway u can use it without problem coz its a constant number, have alot constant in game (like PLAYER_NEUTRAL_PASSIVE, UNIT_TYPE_HERO etc etc), dont have nothing bad if u use constant instead do a useless calculation

anyway in gui hard to use any of them if u dont use custom script :D
 
  • Example
    • Events
    • Conditions
    • Actions
      • Special Effect - Create a special effect at ((Center of (Playable map area)) offset by 250.00 towards 45.00 degrees) using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
This simple gui function should be understandable.
Let's convert it to raw jass.
JASS:
function Trig_Example_Actions takes nothing returns nothing
    call AddSpecialEffectLocBJ( PolarProjectionBJ(GetRectCenter(GetPlayableMapRect()), 250.00, 45.00), "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" )
endfunction

//===========================================================================
function InitTrig_Example takes nothing returns nothing
    set gg_trg_Example = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Example, function Trig_Example_Actions )
endfunction
GUI is simple interface it will just link BJ functions together and form script.
Let's take a closer look at this line here:
PolarProjectionBJ(GetRectCenter(GetPlayableMapRect()), 250.00, 45.00)
When we split it, we got:
JASS:
/* We can ignore this part
function GetPlayableMapRect takes nothing returns rect
    return bj_mapInitialPlayableArea
endfunction

function GetRectCenter takes rect whichRect returns location
    return Location(GetRectCenterX(whichRect), GetRectCenterY(whichRect))
endfunction
*/
function PolarProjectionBJ takes location source, real dist, real angle returns location
    local real x = GetLocationX(source) + dist * Cos(angle * bj_DEGTORAD)
    local real y = GetLocationY(source) + dist * Sin(angle * bj_DEGTORAD)
    return Location(x, y)
endfunction
Sin and Cos are defined from -1 to 1.
But both trigonometric functions use radians.
angle * bj_DEGTORAD will convert degree into radian, bj_DEGTORAD is blizzard constant for 3.14/180.

It's there to allow use to use degrees in our math formulas, well in GUI.
You can use numbers in jass just like that.
Example for 45 degrees you can just go with Sin(0.785398163) or Cos(0.785398163) or even better 0.707106781 (result of those 2) and it will work fine.

It's real constant, no memory or handle leaks.

bj_RADTODEG is another constant that reverse process :)
 
Level 7
Joined
Jan 28, 2012
Messages
266
the bj_RADTODEG converts radians to degrees, it deals with the ratio of radians to degrees as everyone before me has stated.
Do you know what a radian is? if not then
a radian is an angular measurement of an arc that any circles radius will make imagine taking a piece of string that was the length of some circles radius and wrapping it around its circumfrence, the angle measurment between the two points will be about 57 degrees.
I wish i could explain better but this is a concept better explained with pen and paper then with 0's and 1's
 
Status
Not open for further replies.
Top