Vector3
- Angle
- ClampMagnitude
- Cross
- Distance
- Dot
- forward
- Lerp
- magnitude
- Max
- Min
- MoveTowards
- normalized
- Normalize
- one
- operator !=
- operator *
- operator +
- operator -
- operator /
- operator ==
- OrthoNormalize
- Project
- Reflect
- right
- RotateTowards
- Scale
- Slerp
- SmoothDamp
- sqrMagnitude
- this [int index]
- ToString
- up
- Vector3
- x
- y
- zero
- z
Vector3.Slerp 球形插值
static function Slerp (from : Vector3, to : Vector3, t : float) : Vector3
Description描述
Spherically interpolates between two vectors.
球形插值在两个向量之间。
我感觉叫“弧线插值”更直观一些。
Interpolates from towards to by amount t. The returned vector's magnitude will be interpolated between magnitudes of from and to.
通过t数值在from和to之间插值。返回的向量的长度将被插值到from到to的长度之间。
t is clamped between [0...1]. See Also: Lerp function.
t的值在[0...1]。
参见:Lerp函数
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public Transform sunrise;
public Transform sunset;
void Update() {
Vector3 center = sunrise.position + sunset.position * 0.5F;
center -= new Vector3(0, 1, 0);
Vector3 riseRelCenter = sunrise.position - center;
Vector3 setRelCenter = sunset.position - center;
transform.position = Vector3.Slerp(riseRelCenter, setRelCenter, Time.time);
transform.position += center;
}
}
// Animates the position in an arc between sunrise and sunset.
//在日出和日落之间动画弧线
var sunrise : Transform;
var sunset : Transform;
function Update () {
// The center of the arc
//弧线的中心
var center = (sunrise.position + sunset.position) * 0.5;
// move the center a bit downwards to make the arc vertical
//向下移动中心,垂直于弧线
center -= Vector3(0,1,0);
// Interpolate over the arc relative to center
//相对于中心在弧线上插值
var riseRelCenter = sunrise.position - center;
var setRelCenter = sunset.position - center;
transform.position = Vector3.Slerp(riseRelCenter, setRelCenter, Time.time);
transform.position += center;
}
最后修改:2010年12月19日 Sunday 23:34