Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

sin() and cos()... wtf? (c++)

Name: Anonymous 2006-09-04 0:32

Check this out:

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: Anonymous 2006-09-04 1:32

IT IS IN RADIANS, YOU FUCKHEAD

Name: Anonymous 2006-09-04 1:40

P.S. Use
#define DEG2RAD .01745329251994329577f
then do
result1 = cos(direction*DEG2RAD);
result2 = sin(direction*DEG2RAD);
for max performance

Name: Anonymous 2006-09-04 2:16

First of all, you left the c out of the first cout.

Name: Anonymous 2006-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.

Name: Anonymous 2006-09-04 3:49 (sage)

>>5 is still sucking on his mother's breasts, please forgive him.

Name: Anonymous 2006-09-04 4:05

>>5
Don't count on the compiler optimizing anything for you.

Name: Anonymous 2006-09-04 4:45

>>7
True.dat, even though today's C/C++ compilers are almost self-conscious.

Name: Anonymous 2006-09-04 12:22

>>5
how old are you not to know what radians are? unless you've never been to school, you're too dumb to write C++ code.

Name: Anonymous 2006-09-04 12:49

>>5
You might be a horrible programmer if you think the RAD mode on your calculator makes it do extreme skater tricks.

Name: Anonymous 2006-09-04 13:24

result1 = cos(direction*=DEG2RAD);
result2 = sin(direction);
for max performance
fixed

Name: Anonymous 2006-09-04 15:32

>>11
stfu

Name: Anonymous 2006-09-05 1:49

There's no way OP is over 18.

Name: Anonymous 2006-09-05 3:09

This is like the Price is Right.

There's no way the OP is over 14, Bob.

Name: Anonymous 2006-09-05 9:55

>>14
NO ZERO. DO I WIN??

Name: Anonymous 2006-09-05 16:48

>>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: Anonymous 2006-09-05 16:48

19btw

Name: Anonymous 2006-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: Anonymous 2006-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: Anonymous 2006-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: Anonymous 2006-09-05 20:15

Also, what I'm writing is going to be basically like cave story.  I seriously doubt it took calculus.

Name: Anonymous 2006-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: Anonymous 2006-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: Anonymous 2006-09-05 20:39

BTW, thanks for the help, those who did, even if it turned out I didn't really need it.

Name: Anonymous 2006-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: Anonymous 2006-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.

Name: Anonymous 2006-09-05 21:05

You dumb

Name: Anonymous 2006-09-05 21:43

Me smert

Name: Anonymous 2006-09-05 22:38

>>28
no u dumb

Name: Anonymous 2006-09-06 0:38 (sage)

>>25
>>26
Not every school is the same.

Name: Anonymous 2006-09-06 1:08

>>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: Anonymous 2006-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: Anonymous 2006-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: Anonymous 2006-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!

Name: Anonymous 2006-09-06 4:06 (sage)

>>33
AP doesn't count for shit. lol nerds

Name: Anonymous 2006-09-07 4:00

I went to (debatably) THE top school in Australia and they taught us about radians. Worked it out on my own before then though.

BLITHESOME OUR HEARTS ARE AND FREE IS OUR FANCY

Name: Anonymous 2006-09-07 4:26

>>36
asstralia is gay

Name: Anonymous 2006-09-07 7:12

Name: Anonymous 2006-09-07 9:17 (sage)

>>38 is homophobic.

Name: Anonymous 2006-09-07 10:48

>>38 is homofag

Name: Anonymous 2006-09-07 19:55

>>38 is gaybicfag

Name: Anonymous 2006-09-08 1:11

FACE IT, AMERICA'S SCHOOL SYSTEMS ARE SUFFERING BECAUSE THE GOVERNMENT KNOWS YOU DON'T HAVE TO BE SMART TO SHOOT "SAND NIGGERS", AND THEY'LL WASTE MONEY IF THEY TRY TO TEACH YOU, CAUSE YOU'LL JUST GET SPLATTERED OR GET UPPITY DUE TO YOUR INTELLIGENCE ANYWAY.

Name: Anonymous 2006-09-08 2:25

So like. People are actually bragging about knowing radians?

My son, 9 years old, knows the difference between a degree and a radian. And he just tried to use a fork to open a can of corn. This states his level of intelligence.

Name: Anonymous 2006-09-08 4:23

>>43
he just tried to use a fork to open a can of corn
An awesome idea! Gotta try that when I get home, thanks for the tip! I never knew how to open those damned cans.

Name: Anonymous 2006-09-08 8:20

>>43
No, we're mocking the OP for not knowing about radians, because they're such a basic and essential concept.

Name: Anonymous 2006-09-09 1:08

I thought >>38 said homophones...

Name: Anonymous 2006-09-09 1:08

>>43
You obviously come from a math family.  I didn't.

Name: Anonymous 2006-09-09 1:09

>>43
You obviously come from a math family.  I didn't.

Name: Anonymous 2006-09-09 1:12

People always assume that everyone is exactly like them, and make all their judgements based on themselves.  Programmers, Mathmaticians, people interested in extremely analytical stuff tend to do that.   I don't know why.

Name: Anonymous 2006-09-09 1:27

>>49
You're still fucking stupid, and don't belong in programming.  STFU.

Name: Anonymous 2006-09-09 8:26

>>49
Your logic is retarded. Maths is easy.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List