数学基础知识之Sin、cos画圆
2016-07-13 12:27
651 查看
由于在控制台里面画圆的时候,SetCursorPosition该函数只接受Int类型的数据 所以位置就会四舍五入,这样就画的不正确 所以采用Uniyt中的2D界面绘制的 主要是巩固math.sin和math.cos函数
void DrawCircle() { float x = obj.transform.localPosition.x; float y = obj.transform.localPosition.y; float radir = 200; for (int i = 0; i < 90; i++) { //第一象限 Vector3 vc = Vector3.zero; vc.x = x + radir * Mathf.Cos(Mathf.PI / 180 * i); vc.y = y + radir * Mathf.Sin(Mathf.PI / 180 * i); GameObject tmpObj = Instantiate(obj.gameObject); tmpObj.transform.parent = obj.transform.parent; tmpObj.transform.localPosition = vc; tmpObj.transform.localScale = Vector3.one; //第四象限 vc.y = y - radir * Mathf.Sin(Mathf.PI / 180 * i); tmpObj = Instantiate(obj.gameObject); tmpObj.transform.parent = obj.transform.parent; tmpObj.transform.localPosition = vc; tmpObj.transform.localScale = Vector3.one; //第二象限 vc = Vector3.zero; vc.x = x - radir * Mathf.Cos(Mathf.PI / 180 * i); vc.y = y + radir * Mathf.Sin(Mathf.PI / 180 * i); tmpObj = Instantiate(obj.gameObject); tmpObj.transform.parent = obj.transform.parent; tmpObj.transform.localPosition = vc; tmpObj.transform.localScale = Vector3.one; //第三象限 vc.y = y - radir * Mathf.Sin(Mathf.PI / 180 * i); tmpObj = Instantiate(obj.gameObject); tmpObj.transform.parent = obj.transform.parent; tmpObj.transform.localPosition = vc; tmpObj.transform.localScale = Vector3.one; } }
相关文章推荐
- Javascript 绘制 sin 曲线过程附图
- unity实现多点触控代码
- 在Unity中实现动画的正反播放代码
- Unity UGUI教程之实现滑页效果
- unity实现摄像头跟随
- Unity3D上路_01-2D太空射击游戏
- Unity3D上路_02-第一视角射击游戏
- Unity3D上路_03-塔防游戏
- Unity3D上路_04-基础资源介绍
- Unity3D上路_05-网络相关
- Unity3D-5.3.5发布VR项目到Android
- unity 新UI草稿
- [软件资讯]Unity已支持将3D游戏导出成Flash
- Qos、Tos、Cos、DSCP
- ShaderLab: Pass
- Unity 武器拖尾效果
- COS系统被扒皮,原为Sense6.0泄露版
- mls qos cos
- unity常见问题之20题
- Unity3D动画存储插件