java三角函數
① java中三角函數怎麼調整精度問題,好像sin30=0.499999994,怎麼才能調整為0.5求指導
用String.format("%.3f",f);//要保留幾位數中尺字變為首賀幾者培派即可,自動四捨五入
② java Math 三角函數 cot
java.lang里沒定義這2個函游含臘數,用Math.sin Math.cos相除也可以得出神滑cot arccot正切餘切老判的
③ java 勾股定理,與三角函數cos sin tan 兩個算出的結果不一樣,求解釋
a/Math.cos(45.00)
你錯在了譽侍這里,你輸出的45.00你自己認為是度數45°,其實是double = 45.00
你需要先轉化45.00到度數,然後再用上慶段吵邊的燃茄
a/Math.cos(Math.toRadians(45.00))
static double toRadians(doubleangdeg)
Converts an angle measured in degrees to an approximately equivalent angle measured in radians.
④ java arctan
java arctan是什麼,讓我們一起了解一下?
arctan是java中數學運算的三角函數方法,tan() 三角正切,通過編程Java代碼實現,常用的還有cos() 三角餘弦,sin()為 三角正弦,asin() 正弦的反函數,cos() 餘弦的反函數,tan() 正切皮寬的反函數。
他的源代碼如下:
public class 模鄭MainTest { public static void main(String[] args) { //求sin值 double sin = Math.sin(3.14); System.out.println("sin3.14=" + sin); //求cos值 double cos = Math.cos(0); System.out.println("cos0=" + cos); //求tan值 double tan = Math.tan(0.785); System.out.println("tan0.785=" + tan); //求arcsin double arcsin = Math.asin(1); 燃碼亮 System.out.println("arcsin1 = " + arcsin); //求arccos double arccos = Math.acos(1); System.out.println("arccos = " + arccos); //求arctan double arctan = Math.atan(30); System.out.println("arctan30 = " + arctan); //求弧度 double radians = Math.toRadians(180); System.out.println("180度角的弧度為" + radians); //求角度 double angle = Math.toDegrees(3.141592653589793); System.out.println("π的角度數為" + angle); //求以e為底的指數 double exp = Math.exp(1); System.out.println("以e為底指數為1的數為" + exp); //求以e為底e的平方的對數 double log = Math.log(Math.E * Math.E); System.out.println("以e為底e的平方的對數" + log); //求以10為底100的對數 double log10 = Math.log10(100); System.out.println("以10為底100的對數" + log10); //求100的平方根 double sqrt = Math.sqrt(100); System.out.println("100的平方根是" + sqrt); //求27的立方根 double cbrt = Math.cbrt(27); System.out.println("27的立方根是" + cbrt); //求10除以3的余數 double rest = Math.IEEEremainder(10, 3); System.out.println("10除以3的余數為" + rest); //求0.9向上取整 double ceil = Math.ceil(0.9); System.out.println("0.9向上取整" + ceil); //求2.49向下取整 double floor = Math.floor(2.49); System.out.println("2.49向下取整" + floor); //求最接近參數的整數值(若有兩個滿足條件的數據則取為偶數的數據) double rint = Math.rint(3.5); System.out.println("最接近參數的整數值" + rint); //獲得(1,1)坐標與x軸夾角度數 double atan2 = Math.atan2(1, 1); System.out.println("坐標(1,1)的極坐標為" + atan2); //求3的5次方 double pow = Math.pow(3, 5); System.out.println("3的5次方" + pow); //4舍5入 double round = Math.round(3.5); System.out.println("3.5四捨五入為" + round); //計算2
⑤ JAVA計算三角函數公式
已經知道兩條邊和一個直角了,可以把另一條邊求出來(根據A2+B2=C2),然後根據公式
cosA=(a2+b2-c2)/(2ab) 其中A為邊a b的夾角!
⑥ 用java怎麼實現以度為單位的三角函數計算
就以cos為例吧:
int x;//表示你定義好的一個數
System.out.println(Math.cos(x*Math.PI/180));
你輸入一個60,得到是0.5,結果正確,所以那個60就表示60度,當亂吵正然計算機在這其中進行一步轉換為弧度數進行計算。
當x*Math.PI/180這條轉換語句去掉直接Math.cos(60),則碰耐輸出錯誤的答案。
所以你這個問題就好像問,計算機怎麼實現用10進制去處理信息。嘩悔