0

Just puzzling me the Error shown on firebug console:

Uncaught TypeError: Object #<Object> has no method 'Sin'
Uncaught TypeError: Object #<Object> has no method 'Cos'

yet my code gives the value for Math.PI

I'm totaly confused, I can't figure out what i did wrong, any help is greatly appreciated.

My code:

function callCordinates(angle){
    console.log(Math.PI); // shows 3.14...
    console.log(Math.Cos(0)); // throws error. :(

    var x1 = 480 + 100 * Math.Cos(angle * (Math.PI / 180));
    var y1 = 155 + 100 * Math.Sin(angle * (Math.PI / 180));
}

Processing URL parameters

Im building a custom site with PHP, and its almost like a CMS, here I will have categories, subcategories and pages/posts, so my expected URL is like

mysite.com/category/sub-category/page-name/

and this hierarchy is not constant, I may get 3 or more subcategories, and I will also have pagination parameters in same URL like

mysite.com/category/sub-category/page-name/6

So, in my site index.php will only handle all the URLs as like in other CMS, but Im not sure how to split this url and how to know which is page name, which pagination param, which is category parameter and all, please help me in achieving this.

4

3 に答える 3

2

そのMath.sin、変更

Math.Sin(angle * (Math.PI / 180));

Math.sin(angle * (Math.PI / 180));

およびそのMath.cos、次のように変更します。

Math.Cos

Math.cos
于 2013-10-22T09:07:06.130 に答える
1

慣例により、定数はすべて大文字で、JS の関数は小文字です。 Math.PIは定数であるMath.Eため、大文字で表記されます。一方、、、、sinおよびその他は関数であるため、小文字で表記されます。costan

この場合、Math.SinあるべきでMath.sinあり、Math.CosあるべきですMath.cos

于 2013-10-22T09:08:41.537 に答える