JS Math.sin() 与 Math.cos() 用法
来源:互联网 发布:淘宝安能物流被禁用 编辑:程序博客网 时间:2024/05/22 00:39
Math.sin(x) x 的正玄值。返回值在 -1.0 到1.0之间;
Math.cos(x) x 的余弦值。返回的是 -1.0 到1.0之间的数;
这两个函数中的X 都是指的“弧度”而非“角度”,弧度的计算公式为:2*PI/360*角度;
30° 角度 的弧度 = 2*PI/360*30
如何得到圆上每个点的坐标?
解决思路:根据三角形的正玄、余弦来得值;
假设一个圆的圆心坐标是(a,b),半径为r,
则圆上每个点的X坐标=a + Math.sin(2*Math.PI / 360) * r;Y坐标=b + Math.cos(2*Math.PI / 360) * r;
如何求时钟的秒针转动一圈的轨迹?
假设秒针的初始值(起点)为12点钟方向,圆心的坐标为(a,b)。
解决思路:一分钟为60秒,一个圆为360°,所以平均每秒的转动角度为360°/60 = 6°;
for(var times=0; times<60; times++) {
var hudu = (2*Math.PI / 360) * 6 * times;
var X = a + Math.sin(hudu) * r;
var Y = b - Math.cos(hudu) * r //注意此处是“-”号,因为我们要得到的Y是相对于(0,0)而言的。
}
阅读全文
0 0
- JS Math.sin() 与 Math.cos() 用法
- JS Math.sin() 与 Math.cos() 用法
- Js Math.sin() 与 Math.cos() 用法
- JS Math.sin() 与 Math.cos() 用法
- JS Math.sin() 与 Math.cos() 用法
- JS Math.sin() 与 Math.cos() 用法
- JS Math.sin() 与 Math.cos() 用法(画圆)
- Math.sin() 与 Math.cos() 用法
- js Math.cos()与Math.sin()
- JS 中 Math 对象的【三角函数】的用法与实战例子【打靶游戏】 | Math.tan(), Math.cos(), Math.sin()
- JS Math.sin() 与 Math.cos() 用法 (含圆上每个点的坐标)
- cocos2d-js使用Math.sin(),Math.cos()
- Math.cos()和Math.sin()和Math.atan()
- js中处理Math.cos
- 引用<Math.h>编译sin、cos时无法通过【待续】
- 利用Math.cos和Math.sin计算当前角度所对应方位
- JS:Math.random(),Math.ceil(),Math.floor()与Math.round()
- JS之Math用法
- config.json文件
- ERP标准物料编码规则及方法
- RMAN 备份与恢复 实例
- LeetCode 387. First Unique Character in a String
- RN版本项目实战升级,工程化相关技术tips,实用, mark.
- JS Math.sin() 与 Math.cos() 用法
- 浏览器中User-Agent的来龙去脉
- React native 常用第三方件总结
- 拍照和选择相册(兼容高版本)
- 【全解析】屏幕尺寸/分辨率/像素/PPI之间到底什么关系?
- JS中Math.ceil()和Math.floor(x)的使用
- 【python】lambda表达式、filter()、map()
- Android 界面的模板化设计
- 使用HttpURLConnection通过post请求服务器时,URLEncode编码的必要性