double direction, length, result1, result2;
out << "direction?\n";
cin >> direction;
result1 = cos(direction);
result2 = sin(direction);
cout << result1 << "\n";
cout << result2 << "\n";This code is fucked up, because when I enter 45, it should return the same value (.70786 or something similar). Instead, I get:
0.525322 (cos)
0.850904 (sin)
It's almost like the C++ library is fucked up or something. I know I haven't forgotten basic geometry (windows calculator bears this out) and I don't think I'm going insane, so WHAT AM I DOING WRONG?
Name:
Anonymous2006-09-04 1:32
IT IS IN RADIANS, YOU FUCKHEAD
Name:
Anonymous2006-09-04 1:40
P.S. Use
#define DEG2RAD .01745329251994329577f
then do
result1 = cos(direction*DEG2RAD);
result2 = sin(direction*DEG2RAD);
for max performance
Name:
Anonymous2006-09-04 2:16
First of all, you left the c out of the first cout.
Name:
Anonymous2006-09-04 3:11
>>3
Yeah, I found it out after about 30 minutes of research... Never even fucking heard of radians...
Doesn't the compiler like, optimize it to the same assembly, even if I just make it a straight up global variable (It's const'd, but still)?
Not an experienced programmer, don't claim to be, so spare the "STFU HOW COULD YOU NOT FUCKING KNOW THIS?" shit.
>>9
not a math guy. Never went above geometry in highschool. It just didn't interest me.
Now I got into indie games, and so, surprise, it does interest me.
Name:
Anonymous2006-09-05 16:48
19btw
Name:
Anonymous2006-09-05 17:12
>>16
Uh, you should have learned about radians in high school geometry. Not to mention good luck working on "indie games" with that level of math knowledge, since even rudimentary physics will require at least a basic grasp of calculus.
Name:
Anonymous2006-09-05 18:35
Not to mention vector and matrix maths, plus all the graph algorithms from discrete maths. If you don't have a head for maths you're pretty much fucked as a programmer. The best you'll be able to do is PHP shitware, or maybe ZOMG ENTERPRISE software. Games? Not gonna happen.
Name:
Anonymous2006-09-05 20:12
>>18
Why? If I can know the formulas, I can easily convert them into code. I didn't say that I wasn't good at math, just that I don't enjoy it.
Name:
Anonymous2006-09-05 20:15
Also, what I'm writing is going to be basically like cave story. I seriously doubt it took calculus.
Name:
Anonymous2006-09-05 20:26
All of you 40-year-old faggots think that schools are still as good as they were before. I'm 18, and despite taking most of the higher-level classes and having a good memory, I never learned about radians, much less any calculus. The schools teach you nothing anymore. I know for a fact that if I had just bought all my high school textbooks and read through them in two or three weeks, I'd learn more than I would going to school, as many of my teachers couldn't even teach half of their books because schools and classes are so large and bloated and full of semi-retarded children.
Name:
Anonymous2006-09-05 20:37
>>22
Heh, yeah... I now know more about geometry than I ever learned in school, just from typing stuff like "how to tell the angle of a line from two points" into google. (I later found out you have to treat the points as ends of a right triangle with the origin, but still).
I can learn everything I need to know from the information that's out there, and from posting shit in places like here. I only posted this because the problem I had didn't immediately reveal itself to solutions.
The point is that I'll learn about 100x more if I give a shit than if I don't.
Name:
Anonymous2006-09-05 20:39
BTW, thanks for the help, those who did, even if it turned out I didn't really need it.
Name:
Anonymous2006-09-05 20:39
>>22
I'm 20, finished public high school in the US two years ago and took: geometry, precalc, calc 1, calc 2, calc 3, linear algebra (the previous four being one semester each). Stop blaming the schools for your personal mediocrity.
Name:
Anonymous2006-09-05 20:48
Second on the stop blaming schools. I took finished calc 1 in hs. And I could easily have finished all of >>25 in college first year.
>>30
Not every school offers higher math classes, but if you make it through high school without learning about radians it is your own fault.
Name:
Anonymous2006-09-06 2:39
(Note: I'm not >>1->>31.) Most I use, I learnt it on my own. School stuff were either botched with low-quality teachers and bloated classes with morons in them, or long forgotten because I was always half asleep, fucking boredom. Then I began self-teaching me everything I needed and everything I felt curiosity for, including advanced Maths.
Name:
Anonymous2006-09-06 2:44
>>31
I went to one of THE top-rated public schools in America (based on amount of AP and higher level classes offered) and I didn't learn any of this shit. I got straight A's but had to stop right before AP Calculus because of bullshit caused by a school I moved from. However, the people who did take that AP class said it was one of the easiest they took, and that they didn't learn SHIT. And I know why : every single school I've been to, rural, urban, middle of nowhere, middle of downtown, have always been WAY too fucking crowded. Because of the education funding cuts in the last few years, undertrained teachers are left to teach VERY crowded classes, with half of the teachers not even having their own rooms in some cases, and as a result, everyone suffers. Many schools do NOT effectively teach higher level math classes, and as such many students do not learn concepts fundamental to others' understanding of math.
Name:
Anonymous2006-09-06 3:22
>>33
I went to something like THE 700th place public school in America and it offered a wider range of classes and apparently had better teachers than one of THE top-rated public schools. Crazy!