Click to See Complete Forum and Search --> : Math.pow/Math.sin Question


nvibest
09-26-2008, 08:56 PM
Hello,
I'm writing a program with an equation that involves Math.sin, and I was wondering how, exactly, do you square Math.sin. Do you write it like so......?
A = Math.sin(Math.pow(sin, 2))


Some help with this would be greatly appreciated.
Thanks,

M

starheartbeam
10-07-2008, 01:32 PM
here is an example:

double a = square(Math.sin(dlat/2))
+ Math.cos(lat1)*Math.cos(lat2)*square(Math.sin(dlong/2));
double c = 2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a)); // angle in radians formed by start point, earth's center, & end point
double r = globeRadiusOfCurvature((lat1+lat2)/2); // radius of earth at midpoint of route
return r*c;

FourCourtJester
10-07-2008, 01:43 PM
Math.pow(x, y) returns the x raised to the yth power.

Thus, result = Math.pow(sin, 2) will return the variable 'sin' squared.

Math.sin(s) will return the Sine of the variable 's'

Thus, result = Math.sin(s) will return the Sine of the variable 's'.

So try this:

foo = Math.pow(sin, 2);
a = Math.sin(foo);

Should work.