Reputation: 4163
I am having trouble understanding a function hopefully someone can help me out here. I am trying to find the pitch diameter of a sprocket the function for this in JavaScript is:
function sprocket_diam(dataform,pitch,teeth)
{
var a,b,c,d,e;
a = pitch / 2;
b = teeth * 2;
c = 360 / b;
d = Math.sin ((c * Math.PI) / 180);
e = (a / d) * 2
dataform.diam.value = e;
}
The above function works just as intended but I am trying to do this by hand on a calculator. I think the problem I am having comes in the d
variable. For example lets say I have a 15
tooth sprocket with a pitch of .5"
. Using the above formula the numbers for the variables I get are:
a=0.25
,b=30
,c=12
, and for d
I take (12*3.14)/180
which gives me 0.2093
so e=(0.25/.2093)*2
which ends up being 2.388915432
but is the incorrect answer it should be 2.404867172372066
Can someone point out what I am doing wrong? I have always struggled with math.
Upvotes: 0
Views: 87
Reputation: 382160
Your error is that you do as if Math.PI
would be 3.14
.
If you use the precise value of Math.PI
, you get 12*Math.PI/180 == 0.20943951023931953
instead of the 0.2093
you use and at the end you find 2.404867172372066
Upvotes: 1