using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//ab =|a| |b|cos(x),ab夹角
//b在a上的投影:|b|cos(x) = (a
b)/|a| = ba(A),//单位矢量a
/

a为平面法线,求b在平面上的投影
b在a向量上的投影向量为c = Vector.Dot(a,b)/a.magintude ()*a.normalized
则b在平面上的投影为:b-c;
*/
//点乘Vector3.Dot();
//叉乘Vector3.Cross();(左手顺时v1指向v2)。即叉乘的第一个向量在第二个向量右边时为正,否则为负。
public class VectorAPI : MonoBehaviour
{
public AnimationCurve cuver;
private float x;
public float psTime=3;
private Vector3 targetPoint = new Vector3 (0, 0, 10);
private void OnGUI()
{
if (GUILayout.RepeatButton ("Move"))
{
//将物体移动至(0,0,10)
//匀速移动
this.transform.position = Vector3.MoveTowards(this.transform.position,targetPoint , 2);
//先快后慢--终点与比例固定
this.transform.position = Vector3.Lerp (this.transform.position, targetPoint , 2 );

    }
    if (GUILayout.RepeatButton("Lerp"))
    {
        x += Time.deltaTime/psTime ;
        //自然变化,起点,终点固定,比例根据曲线变化
        this.transform.position =
            Vector3.LerpUnclamped (Vector3.zero, targetPoint, cuver.Evaluate(x));
    }
}

}