zoukankan      html  css  js  c++  java
  • 向量

    加法

    可计算位移

    U + V 

    减法

    求得两个向量的方向

    U-V = VU

    using UnityEngine;
    using System.Collections;
    
    public class Test : MonoBehaviour {
    
        private Vector3 target = new Vector3(100,0,100);
        private Vector3 normal;
        // Use this for initialization
        void Start () {
    //U - V = VU normal
    = (target - transform.position).normalized; } // Update is called once per frame void Update () { if (Vector3.Distance(target,transform.position) > 0.1) { transform.position += 0.1f * normal; } else { transform.position = target; } } }

    点乘

    Unity中用于计算角度

    一般来说,点乘结果描述了两个向量的“相似”程度,点乘结果越大,两个向量越相近,

    点乘和向量间的夹角相关 

    计算两向量间的夹角    θ = arccos(a·b)

    叉乘

    叉乘得到的向量垂直于原来的两个向量。

    a × b 的长度等于向量的大小与向量夹角sin值的积,||a × b|| = ||a|| ||b|| sinθ 

    • 叉乘最重要的应用就是创建垂直于平面、三角形、多边形的向量。
  • 相关阅读:
    Django学习2
    Django学习1
    python 基于tcp协议的文件传输3_解决粘包问题
    python socketserver
    python hashlib
    python struct模块
    python json 模块
    python socket模块
    13暑假集训#10 总结
    hdu 4493 卡输入输出
  • 原文地址:https://www.cnblogs.com/lu-zw/p/5204162.html
Copyright © 2011-2022 走看看