Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - PocketC help
Page 1 of 1

PostPosted: Sat Oct 12, 2002 7:07 pm
by fishTail
Help! I am a PocketC beginner and have written some simple programs already. However, I have tried writing programs incorporating Trig functions and do not get the expected result from them.

i.e Tan 30 degrees=-6.405
when I am expecting 0.5773502 or similar.

Any help for what I am doing wrong would be appreciated.

PostPosted: Sat Oct 12, 2002 9:01 pm
by samps
You're getting the wrong values (actually you're getting the RIGHT answers to the wrong questions) because PocketC is using RADIANS, not DEGREES

To get the expected TAN value you'll have to convert from degrees to radians before calling tan()...

Your angle, 30 degrees, is 30/360th of a circle, and a circle is 2*pi radians



//tans

float angle;
main()

{
angle=30.0/360*6.28;
alert(tan(angle));
}


you'll get used to it

Samps

PostPosted: Sun Oct 13, 2002 5:32 am
by wolfgang
A little more exact (I don't know how many digits you need), but for PocketC float calculations having about 7 significant digits, better use 3.1415927 for PI instead of 3.14 as used in the previous post.

Wolfgang

Composing music on the PocketPC! - http://www.pdamusician.com

PostPosted: Sun Oct 13, 2002 11:39 am
by fishTail
Many thanks for answer.:D I wish textbooks had expanded a little more on topic. I'd been wrestling with that one for a while and couldn't find any examples/ code anywhere with trig. in them.
Straight forward once you know, but for a beginner.....

PostPosted: Sun Oct 13, 2002 2:42 pm
by soinsg
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by samps</i>
<br />angle=30.0/360*6.28;
<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">

You code probably make this faster my combining the 360 and the 6.28 as they are both constants (won't change).

<pre id="code"><font face="courier" size="2" id="code">
angle=30.0/1130.973;
</font id="code"></pre id="code">

PostPosted: Mon Oct 14, 2002 7:44 pm
by fishTail
Hi, thanks for input but is that not 30.0/57.2957877

i.e 57.295 etc. not 1130.973 :?:

......but hey, I get the constant idea.

PostPosted: Tue Oct 15, 2002 6:50 pm
by soinsg
57.. is one radian?
and 6.28 is 2 pi radians, which is 360 degrees, wait, I'm confusing myself!

Anyway I figure that you got: 30.0/360*6.28 (from samps)
And following BIDMAS the multiplication and division are on the same level, so you can do 360 * 6.28 = 1130.. then stick that in the original to get 30.0/1130.97