Skip to main content
GameDev.net gamedev.net
🔒 Locked

Math.Cos2 from Math.cos?

Started by socialdev Nov 15, 2011 at 12:48 AM 4 replies 1.3k views
Original Post
socialdev
socialdev
I have a little problem here... The language I am using does not have Math.cos2() function, it only has a Math.cos() function. How do I solve this?

I was looking at the wikipedia article on cosigns and am stumped...
http://en.wikipedia.org/wiki/Law_of_cosines

If it's not included in the language it must be something simple like Math.pow(Math.cos(x),2)? (Cos the the power of two.) Dunno...
alvaro
alvaro
I've never heard of cos2. What is it?
TheUnbeliever
TheUnbeliever
If you mean the thing which appears in bb23b7b4674a128b573fcd3239d8dd90.png then that is indeed just cos(x)^2, which you can get using Math.Pow like you say.
[TheUnbeliever]
TomKQT
TomKQT
It's just a little bit confusing way (but fully fine, standard and common) how to write a square of cosinus.
In fact this:
cos[sup]2[/sup]a
simply means:
(cos(a))[sup]2[/sup]

Which really is Math.pow(Math.cos(x),2)
socialdev
socialdev
Awesome, thanks Tom.
Cornstalks
Cornstalks
Just to add. One of the reasons we write it like that is so that it's clear we are taking the square of the result of the cos, and not squaring the angle within the cos. Plus I get to be lazy and not write parenthesis.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.