1.如何在unity写cos60

Mathf.Cos(Mathf.Deg2Rad * )

Deg2Rad将 60 角度转换为弧度,因为里面参数只能填弧度数

2.计算一个Vector3绕旋转中心旋转指定角度后所得到的向量

/// <summary>
/// 计算一个Vector3绕旋转中心旋转指定角度后所得到的向量。
/// </summary>
/// <param name="source">旋转前的源Vector3</param>
/// <param name="axis">旋转轴</param>
/// <param name="angle">旋转角度</param>
/// <returns>旋转后得到的新Vector3</returns>
public Vector3 V3RotateAround(Vector3 source, Vector3 axis, float angle)
{
Quaternion q = Quaternion.AngleAxis(angle, axis);// 旋转系数
return q * source;// 返回目标点
}

注意求出的是向量,转移为坐标得+transfrom,position

【示例】放unity里面,按p键即可看见效果

using System.Collections;
using System.Collections.Generic;
using UnityEngine; public class Draw3 : MonoBehaviour { Vector3 d;
float duShu;
// Use this for initialization
void Start () { } // Update is called once per frame
void Update () {
//按P键加角度
if (Input.GetKeyDown(KeyCode.P))
{
duShu += ;
}
} private void LateUpdate()
{
d = V3RotateAround(transform.forward, transform.up, duShu, );
Debug.DrawLine(transform.position, transform.position + d, Color.red);
} /// <summary>
/// 计算一个Vector3绕旋转中心旋转指定角度后所得到的向量。
/// </summary>
/// <param name="source">旋转前的源Vector3</param>
/// <param name="axis">旋转轴</param>
/// <param name="angle">旋转角度</param>
/// <returns>旋转后得到的新Vector3</returns>
public Vector3 V3RotateAround(Vector3 source, Vector3 axis, float angle, float length)
{
Quaternion q = Quaternion.AngleAxis(angle, axis);// 旋转系数
return q * source * length;// 返回目标点
} }

unity向量-数学-三角函数的更多相关文章

  1. [转] Unity Mathf 数学运算(C#)

    Mathf.Abs 绝对值 计算并返回指定参数 f 绝对值. Mathf.Acos 反余弦 static function Acos (f : float) : float 以弧度为单位计算并返回参数 ...

  2. unity 向量赋值 传引用?传值?

    unity中,Vector2.Vector3之间的任意赋值都是传值 Vector2 v1; ,); v1=v2; v2.x=; Debug.Log(v1);//output: (2.0, 2.0) D ...

  3. Unity 向量点乘、叉乘

    向量点乘计算角度,向量叉乘计算方位 a,b为向量 点乘计算公式:a x b = |a| x |b| x cosθ 叉乘计算公式:a x b = |a| x |b| x sinθ

  4. Unity向量投影使用

    官方例图 测试: code: public Transform point1; public Transform point2; public Transform humanPoint; public ...

  5. Unity Mathf/Math数学运算函数说明全集(Chinar总结)

    Unity Mathf 数学函数库 本文提供全流程,中文翻译. Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) Chinar -- ...

  6. Unity优化方向——优化Unity游戏中的脚本(译)

    原文地址:https://unity3d.com/cn/learn/tutorials/topics/performance-optimization/optimizing-scripts-unity ...

  7. Unity DOTS 走马观花

    https://segmentfault.com/a/1190000019143037 本文还在不断完善,可能不会及时同步在 SegmentFault,源文章在我的博客中:萤火之森 - Unity D ...

  8. Unity 3D 开发 —— 脚本编程

    Unity 相关资源 Unity 官网 :http://www.unity3D.com Unity 论坛 : http://forum.unity3d.com/forum.php Unity 问答 : ...

  9. 3D数学基础学习之向量一

    向量-数学定义 对数学家而言,向量就是一个数字列表,对程序员而言则是另一种相似的概念,数组. 向量-几何定义 a.向量的大小就是向量的长度(模),向量的长度非负 b.向量的方向描述了空间中向量的指向. ...

随机推荐

  1. C# 多线程操作实例

    1.多线程操作 一旦打开线程就必须记得关闭 1.第一部分 这是个数字叠加小功能 private void CountTo(int countTo, CancellationToken ct) { ; ...

  2. C#ADO.NET基础二

    DataAdapter的使用,批量增删改 1.使用DataAdapter查询 private void Select2() { try { using (SQLiteConnection conn = ...

  3. CentOS 进程操作

    ps -ef:查看所有进程, ps -ef |grap firewalld 查看与firewalld相关的进程 which :查看进程:which firewalld kill 进程id:杀掉进程 k ...

  4. C# 由范式编程==运算符引发对string内存分配的思考

    今天在看C#编程指南时(类型参数的约束http://msdn.microsoft.com/zh-cn/library/d5x73970.aspx)看到一段描述: 在应用 where T : class ...

  5. rtabmap and rtabmap_ros make error(rtabmap编译错误)

    Build from source following README.nd in rtabmap_ros rtabmap make error Error 1 make[2]: *** No rule ...

  6. kali linux之防火墙识别

    通过检查回包,可能识别端口是否经过防火墙过滤,设备多种多样,结果存在一定的误差 Send Response   Type SYN   NO    Filtered(先发送syn 如果不给回复 防火墙可 ...

  7. MongDB集群部署

    http://blog.csdn.net/luonanqin/article/details/8497860 参数解释: dbpath:数据存放目录 logpath:日志存放路径 pidfilepat ...

  8. (Keil) Debug & Simulation 操作

    0x00 printf在MCU環境下print debug error message,利用Logic Analyzer模擬MCU register or GPIO狀態. 若是要要使用printf函數 ...

  9. 【转】idea中maven模块编程灰色

    可能是设置中模块的pom.xml文件被忽略了 去掉对勾 转自:https://blog.csdn.net/ethan__xu/article/details/80794060

  10. Javascript 连接两个数组

    JS合并两个数组的方法 我们在项目过程中,有时候会遇到需要将两个数组合并成为一个的情况.比如: var a = [1,2,3]; var b = [4,5,6]; 有两个数组a.b,需求是将两个数组合 ...