• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Where's pi?

Status
Not open for further replies.
Level 8
Joined
Aug 4, 2006
Messages
357
When you're scripting, what is the constant for 'pi' called? In wc3 it was bj_PI. What is it in sc2? Also, are there constants for converting radians to degrees (and vice versa), because in wc3 there were bj_RADTODEG and bj_DEGTORAD. It'd be pretty retarded if I had to make my own constant for pi.
 
Level 1
Joined
Aug 9, 2009
Messages
275
Sad they didn't include Pi, tho it aint really hard just to write 3.14 :p But what should Pi be used for anyway?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Radians are the true angle. Degrees are only used in measurements cause they are nice for them. You do not want to read 179pi/180 for an angle, 179 degrees is much easier.

Its probably cause SC2 was designed for less skilled editors. Any proper programmer wants to use radians and have constants for Pi.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Mathematicians are not going to be writing scripts for galexy, programmers are (as by definition it is programming).

Everything uses radians, it is a joke that degrees are even axcepted.

If it axcepted Pi nativly in the syntax as a number it would be a good language.
 
Level 10
Joined
Nov 28, 2008
Messages
655
Honestly, it's not a big deal. My god, you might have to convert them yourselves if you really feel the need.


Well, it saves a lot of work.

Trig functions and radians are nice.
Trig functions and degrees get messy.

When coding, you have to go through more steps to get the needed info out of trig functions with degrees than with radians.

And all of that crap is just annoying, cuz radians make it all go away!
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
It is a big deal cause its a lot of wasted time. Do you seriously think anything in the SC2 engine works on degrees?

Basically when you get unit facing its probably converting radians to degrees. Then you do your maths on that and finally pass that to a function which converts degrees back into radians. It would be far more efficent to get the radians value, use that and then it can directly used the passed radians value. Would save a lot of floatingpoint maths.
 
Level 8
Joined
Jun 28, 2008
Messages
356
WTF, Why would you use radians? High math? Bullshit. Is it so hard to define em yourself?!

fixed PI = 3.14159265;
fixed RAD_TO_DEG = 180 / PI
fixed DEG_TO_RAD = PI / 180

... Damn! More efficient? Like 5 microseconds less? Yeah.
 
Level 8
Joined
Jun 28, 2008
Messages
356
When the computer does your calculations I don't see much of a difference. Actually I even find it easier with degrees. Whatever, just do it the way you find better ;-) Anyways they most likely excluded PI, because it's onliest use would've probably been converting rad to deg and back, which we don't have to do in sc2 anymore. Unless we actually want to use rads. C'mon just go and define em :] We probably wasted tens of thousands of more time here talking about it than it would ever take you summed up to define it :D
 
Level 15
Joined
Sep 3, 2009
Messages
1,521
lol elfian have you taken any math above algebra I? You'll find out its MUCH easier to work with radians. Plus if they had implemented it would save lets say 1millisecond per call(not true dont listen)
not inside 2 loops one that picks every unit in group and another that reiterates some actions 10 times. this could add up to quite alot.
 
Level 8
Joined
Jun 28, 2008
Messages
356
A simple calculation taking 1 millisecond? If that's true than Galaxy would be like... about a million times slower than C++ and thousands of times slower than Lua. That's impossible. No way it's taking so much time.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Computer trig only works with radians. Thus it is harder for the computer to deal with degrees than radians.


Also we are looking at quite a bit of wasted time. It is atleast 1-2 more floating point opperations (32 bit) which are some of the more expensive opperations time wise (although you arte executing millions a second lol)

I still can not help but feel blizzard has aimed the editor more at kids than adult.
 
Level 10
Joined
Nov 28, 2008
Messages
655
I still can not help but feel blizzard has aimed the editor more at kids than adult.


Have you actually worked with any of the people that Mod?

I was yelled at to use A, B, C, and D, instead of CastingUnit, Damage, SpellLevel, etc...

These are not programmers, they are people who learn to write code. Some of them are somewhat programmers, but most are just kids/adults who learn some syntax.
 
Level 8
Joined
Jun 28, 2008
Messages
356
Ofcourse Blizzard will be making it more user-friendly. They want more people to make maps, hence more people to play the game. But in my opinion, they should've made the editor UBER HARD. So only the most qualified people would make maps and will make good maps.
 
Level 2
Joined
Apr 19, 2008
Messages
6
@Elfian: The most qualified people will make some good map whatever... So you just want other people can't... Very nice of you xD I'm happy Blizz doesn't think as you do, I wouldn't be able to understand a thing if the editor didn't use simplified interface.
If you'd do that, you would improve the rate of good map (but not so much since qualified people can also make bad maps) but you would also decrease their number (unqualified also are able to do good things...)

For the radian/degree, I find radian better but it won't be a terrible loss for me.

Ah and for pi, I don't think it's a problem since the precision of the reals is very very bad... Juste put 3.1416 since the editor cannot be more precise. It won't be longuer than search the pi function.
 
Level 1
Joined
May 8, 2010
Messages
3
I think the point is a lot of physics/math calculations regarding angular or otherwise non-linear calculations require the use of PI and hence radians. Having only "degrees" as the official angular unit just means you have to convert and reconvert repeatedly when doing such calculations. For most people it wont be a problem, but for people doing complex physics and such, those extra redundant conversions add up overtime.

Ultimately, radians can do everything that degrees can do, while there are things that takes much more time and steps to do when using degrees. Degrees only selling point is its nice to look at and simple to understand. But i do agree with Blizzard changing it to degrees as a the main angular unit, because it would be consistent with the rest of the editor and easier for everyone to understand.

I guess it's acceptable for the sake of looking nicer to the general audience, as long as the calculation performance isn't hindered too much.

Sound good to everybody? Maybe people would be happier if they put in sind/cosd along with sin/cos to allow either units to be used? That would be nice.
 
Level 8
Joined
Aug 4, 2006
Messages
357
Juste put 3.1416 since the editor cannot be more precise.
I'd just like to point out that Galaxy uses floating point numbers to represent real numbers. If Galaxy uses 32-bit floats, 23 bits would be dedicated to the mantissa, meaning pi could be represented with up to 7 decimal places. However, it is more likely that Galaxy uses 64-bit (double precision) floats, with 53 bits for the mantissa, so pi could be represented with up to 16 decimal places. In GUI you can enter more digits than 3.1416, but it will only display 4 decimal places.
 
Level 2
Joined
Dec 1, 2007
Messages
11
It's not world ending, but it does piss off a bunch of people, and it wouldn't have taken all that much work to include. And as Dr_Super_Good mentioned, it's highly doubtful they use degrees internally.
 
Status
Not open for further replies.
Top