zoukankan      html  css  js  c++  java
  • 《Unity_API解析》 第十三、四章 Vector2类、Vector3类

    Vector2类实例方法

    Normalize方法:单位化Vector2实例
    public void Normalize();
    此方法用来单位单位化向量,即将Vector2实例进行单位化处理。此方法改变了原始向量,无返回值。实例属性normalized与此方法功能相同,但使用属性normalized来单位化向量时,不改变原始向量值,且有返回值。
     
    Vector2类静态方法
    Angle方法:两向量夹角
    public static float Angle(Vector2 from, Vector2 to);
    参数from为起始向量,to为结束向量。
    此方法用于返回两个Vector2实例的夹角,单位为角度,返回值的取值范围为[0,180],并且当from和to中至少有一个向量为Vector2.zero的时候返回值为90。
     
    ClampMagnitude方法:向量长度
    public static Vector2 ClampMagnitude(Vector2 vector, float maxLength);
    此方法用于返回向量的长度,且最大不超过maxLength。
     
    Lerp方法:向量差值
    public static Vector2 Lerp(Vector from, Vector2 to, float t);
    参数from为插值的起始向量,参数to为插值的结束向量,参数t为插值系数。
     
    MoveTowards方法:向量差值
    public static Vector2 MoveTowards(Vector2 current, Vector2 target, float maxDistanceDelta);
    参数current为移动起始点坐标,参数target为移动目标点,参数maxDistanceDelta为移动的参考系数。
     
    Scale方法:向量放缩
    public static Vector2 Scale(Vector2 a, Vector2 b);
    此方法用于返回向量a按向量b进行放缩后的值,即向量a,b的乘积。
     
    Vector3类实例属性
    normalized属性:单位化向量
    public Vector3 normalized{get;}
    此属性用来获取Vector3实例的单位向量,即返回向量的方向与原向量方向相同,而模长变为1.
     
    sqrMagnitude属性:模长平方
    public float sqrMagnitude{get;}
    此属性用于返回Vector3实例模长的平方值,即三个分量平方的和。
     
    Vector3类实例方法
    Scale方法:向量放缩
    public void Scale(Vector3 scale);
    此方法可以对Vector3实例按参考向量scale进行放缩,即分量依次相乘。
     
    Vector3类静态方法
    Angle方法:两向量夹角
    public static float Angle(Vector3 from, Vector3 to);
    此方法用于返回向量from和to的夹角,单位为角度,返回值范围为[0,180],且当from和to中至少有一个为Vector3.zero时,方法返回值为90。
     
    ClampMagnitude方法:向量长度
    public static Vector3 ClampMagnitude(Vector3 vector, float maxLength);
    此方法用于返回向量vector的一个同方向向量,模长受maxLength限制。
     
    Cross方法:向量叉乘
    public static Vector3 Cross(Vector3 Ihs,Vecxtor3 rhs);
     
    Dot方法:向量点乘
    public static float Dot(Vector3 Ihs, Vector3 rhs);
     
    Lerp方法:向量差值
    public static Vector3 Lerp(Vector3 from, Vector3 to, float t);
    参数from为差值起始点坐标,参数to为插值结束点坐标,参数t为插值系数。
     
    MoveTowards方法:向量差值
    public static Vector3 MoveTowards(Vector3 current, Vector3 target, float maxDistanceDelta);
    此方法用于返回一个从参数current到参数target的差值向量。
     
    OrthoNormalize方法:两个坐标轴的正交化
    public static void OrthoNormalize(ref Vector3 normal, ref Vector3 tangent);
    此方法用于对向量normal进行单位化处理,并对tangent进行正交化处理。
    即normal变成单位向量,tangent变成与该单位向量垂直的模长为1的向量,且这些向量处于同一平面。
     
    OrthoNormalize方法:三个坐标轴的正交化
     
    public static void OrthoNormalize(ref Vector3 normal, ref Vector3 tangent, ref Vector3 binormal);
    此方法用于对向量normal进行单位化处理,并对向量tangent和binormal进行正交化处理,于上面两个参数的重载相同,binormal垂直于normal和tangent组成的平面。
     
    Project方法:投影向量
    public static Vector3 Project(Vector3 vector, Vector3 onNormal);
    此方法用于返回向量vector在向量onNormal上的投影向量。
     
    Reflect方法:反射向量
    public static Vector3 Reflect(Vector3 inDirection, Vector3 inNormal);
    参数inDirection为入射向量,inNormal为镜面向量
    参数inNormal向量必须为单位向量,否则入射角和反射角不相等。
    当inNormal取反时,反射向量不受影响。
     
    RotateTowards方法:球形插值
    public static Vector3 RotateTowards(Vector3 current, Vector3 target, float maxRadiansDelta, float maxMagnitudeDelta)
    参数current为起始点坐标,参数target为目标点坐标,参数maxRadiansDelta为角度旋转系数,参数maxMagnitudeDelta为模长系数。
     
    Scale方法:向量放缩
    public static Vector3 Scale(Vector3 a, Vector3 b);
    此方法返回向量a和b的乘积。
     
    Slerp方法:球形差值
    public static Vector3 Slerp(Vector3 from, Vector3 to, float t);
    参数from为插值起始点坐标,参数to为插值结束点坐标,参数t为插值系数。
    此方法用于返回从参数from点到参数to点的球形差值向量。
     
    SmoothDamp方法:阻尼运动
    public static Vector3 SmoothDamp(Vector3 current, Vector3 target, ref Vector3 currentVelocity, float smoothTime);
    public static Vector3 SmoothDamp(Vector3 current, Vector3 target, ref Vector3 currentVelocity, float smoothTime, float maxSpeed);
    public static Vector3 SmoothDamp(Vector3 current, Vector3 target, ref Vector3 currentVelocity, float smoothTime, float maxSpeed, float maxSpeed);
    其中参数current为起点坐标,参数target为终点坐标,参数currentVelocity为当前帧移动向量,参数smoothTime为接近目标时的阻尼强度,参数maxSpeed为最大移动速度,默认值为无穷大,参数deltaTime为控制当前帧实际移动的距离,即为maxSpeed*deltaTime,默认值为Time.deltaTime。
  • 相关阅读:
    表空间及组成表空间的物理文件
    MVCC
    innodb结构解析工具---innodb_ruby
    慢查询日志 与 general_log
    思考mysql内核之初级系列
    mysql内核源代码深度解析 缓冲池 buffer pool 整体概述
    change buffer
    python 学习笔记 copy
    xargs
    给tcpdump加点颜色看看
  • 原文地址:https://www.cnblogs.com/colve/p/5979371.html
Copyright © 2011-2022 走看看