Computer Science Canada

Trig Functions

Author:  blaster009 [ Sun Oct 30, 2005 2:57 pm ]
Post subject:  Trig Functions

I can't seem to figure out how to use negative sin in Turing. I need to find the angle of a certain area of pixels, and that requires me to turn the sin equation from [sin angle = opp/hyp] into [angle = sin^-1 (opp/hyp)]. Turing does not seem to have a built-in sin^-1 feature though. Any idea how to get around this (mathematically perhaps)?

Author:  beard0 [ Sun Oct 30, 2005 4:02 pm ]
Post subject: 

sin^-1 is actually only a shorthand for the real name of the function: arcsin, which works in Turing.

Author:  blaster009 [ Mon Oct 31, 2005 11:15 pm ]
Post subject: 

Haha...Yeah, I smacked myself when I found that out today. I was proving Cosine law, and I was like...Arcsin...Oh, my, God.

Author:  md [ Tue Nov 01, 2005 1:35 am ]
Post subject: 

beard0 wrote:
sin^-1 is actually only a shorthand for the real name of the function: arcsin, which works in Turing.


In fact arcsin is the language equivalent to sin^-1, which is just a written notation for the inverse sin function. Mathematical symbols unfortunately generally don't transefer well to computers, so we have to use other names to define things. Yeah it doesn't really help to answer the question, but it's small things like wording that end up throwing people off.

Author:  beard0 [ Tue Nov 01, 2005 9:56 am ]
Post subject: 

Cornflake wrote:
beard0 wrote:
sin^-1 is actually only a shorthand for the real name of the function: arcsin, which works in Turing.


In fact arcsin is the language equivalent to sin^-1, which is just a written notation for the inverse sin function. Mathematical symbols unfortunately generally don't transefer well to computers, so we have to use other names to define things. Yeah it doesn't really help to answer the question, but it's small things like wording that end up throwing people off.


No, arcsine is the real function. sin^-1(x) is simply a shorthand - and a bad and confusing one at that. Does it mean the inverse function of sin(x)? Or maybe is it like sin^2(x)=(sin(x))^2, and it is supposed to be (sin(x))^-1, or 1/(sin(x)). sin^-1 has been defined to be equivalent to arcsine, not the other way around. A subtle but important point.

Author:  codemage [ Tue Nov 01, 2005 12:59 pm ]
Post subject: 

arcsin is the same as the function most calculators show (in shorhand) as sin^-1.

Author:  evildaddy911 [ Wed Dec 21, 2011 10:20 am ]
Post subject:  RE:Trig Functions

so would tan^-1() be arctan()?

Author:  chipanpriest [ Wed Dec 21, 2011 12:28 pm ]
Post subject:  Re: RE:Trig Functions

evildaddy911 @ Wed Dec 21, 2011 10:20 am wrote:
so would tan^-1() be arctan()?

yes Razz

Author:  Alex C. [ Wed Jan 11, 2012 9:52 pm ]
Post subject:  RE:Trig Functions

um, i'm not entirely sure but can you use trigonometry to create bullet paths? :/

Author:  Dreadnought [ Thu Jan 12, 2012 4:08 pm ]
Post subject:  Re: Trig Functions

Alex C. wrote:

um, i'm not entirely sure but can you use trigonometry to create bullet paths? /

Depending on how you want this bullet path to be created, sure. If there's some sort of angle at which you want this path it's likely that trig will be involved.

Author:  Raknarg [ Thu Jan 12, 2012 8:46 pm ]
Post subject:  RE:Trig Functions

If you have the angle of the bullet, then this would give you the velocities of the x and y coordinates:

Turing:

var bulletAngle : int := 0 %this is the angle you'd use
var vbx, vby : real %velocities of bullet
var speed : real := 5 %the distance you want the bullet to travel each iteration

vbx := speed * cosd (bulletAngle)
vby := speed * sind (bulletAngle)


There are more ways to do it, but thats how I do it.

NOTE: If you use degrees, put d at the end of the function (such as sind, arctand). Otherwise, you're calculating things in radians


: