vector.Vector3
- class vector.Vector3(x: float = 0.0, y: float = 0.0, z: float = 0.0)
Class for representing points or directions in space as three float values.
A
Vector3is an immutable object, so it’s x, y, and z properties cannot be changed, and all of its methods return newVector3s without modifying the original.In addition to the methods documented here,
Vector3also supports infix operators such as+,-between vectors,*between a vector and afloatwhen the vector occurs on the left, and unary-equivalent to multiplying by -1.Vector3also implements the__getitem__method for indices0,1,2. So you can access thex,y,zcomponents of a vectorvasv[0],v[1], andv[2]respectively. Negative values and slices work in the usual way for python iterables.Generally, methods that take in a vector also accept 3-tuples or lists of length 3.
Under the hood, this class is implemented by the Unity Engine’s Vector3 class. More documentation can be found here.
- property x: float
- property y: float
- property z: float
- magnitude() float
Returns the magnitude of the vector.
See https://docs.unity3d.com/ScriptReference/Vector3-magnitude.html.
- static normalize(v: Vector3) Vector3
Returns a normalized vector in the same direction as v.
See https://docs.unity3d.com/ScriptReference/Vector3-normalized.html.
- static dot(v: Vector3, u: Vector3) float
Returns the dot product of
vandu.See https://docs.unity3d.com/ScriptReference/Vector3-operator_multiply.html.
- static scale(v: Vector3, s: float) Vector3
Returns a vector equivalent to
vscaled bys.See https://docs.unity3d.com/ScriptReference/Vector3-operator_multiply.html.
- static cross(v: Vector3, u: Vector3) Vector3
Returns the cross product of
vandu.See https://docs.unity3d.com/ScriptReference/Vector3.Cross.html.
- static project_onto_vector(original: Vector3, normal: Vector3) Vector3
Returns the projection of
originalontonormal.See https://docs.unity3d.com/ScriptReference/Vector3.Project.html.
- static project_onto_plane(point_to_project: Vector3, plane_normal: Vector3) Vector3
Returns the projection of
point_to_projectontoplane_normal.See https://docs.unity3d.com/ScriptReference/Vector3.ProjectOnPlane.html.
- static lerp(start: Vector3, end: Vector3, t: float) Vector3
Returns a vector which is
tpercent of the way betweenstartandend.See https://docs.unity3d.com/ScriptReference/Vector3.Lerp.html.
- static angle(source: Vector3, destination: Vector3) float
Returns the angle in radians between
sourceanddestination.See https://docs.unity3d.com/ScriptReference/Vector3.Angle.html, but in radians.
- static angle_degrees(source: Vector3, destination: Vector3) float
Returns the angle in degrees between
sourceanddestination.See https://docs.unity3d.com/ScriptReference/Vector3.Angle.html.
- static clamp_magnitude(v: Vector3, length: float) Vector3
Returns a vector in the direction of
vwith magnitude ofmax(v.magnitude,length).See https://docs.unity3d.com/ScriptReference/Vector3.ClampMagnitude.html.
- static lerp_unclamped(start: Vector3, end: Vector3, t: float) Vector3
Returns a vector which is
tpercent of the way betweenstartandend. Iftis less than0or greater than1, the value is extrapolated.See https://docs.unity3d.com/ScriptReference/Vector3.LerpUnclamped.html.
- static max(v: Vector3, u: Vector3) Vector3
Returns a vector equivalent to
Vector3(*[max(a,b) for a,b in zip(v,u)]).See https://docs.unity3d.com/ScriptReference/Vector3.Max.html.
- static min(v: Vector3, u: Vector3) Vector3
Returns a vector equivalent to
Vector3(*[min(a,b) for a,b in zip(v,u)]).See https://docs.unity3d.com/ScriptReference/Vector3.Min.html.
- static move_towards(current: Vector3, target: Vector3, max_distance: float) Vector3
Returns a vector that is as close to
targetas possible while being at mostmax_distancefar fromcurrent.See https://docs.unity3d.com/ScriptReference/Vector3.MoveTowards.html.
- static orthonormailze(normal: Vector3, tangent: Vector3, binormal: Optional[Vector3] = None) Tuple[Vector3, Vector3, Optional[Vector3]]
Returns vectors that are orthoganal to each other and normal.
normalwill stay pointed in the same direction, but the other argument(s) may be redirected to be orthoganal to each other. Ifbinormalis supplied, a third result will be in the returned tuple, otherwise it will be left asNone.See https://docs.unity3d.com/ScriptReference/Vector3.OrthoNormalize.html.
- static reflect(normal: Vector3, direction: Vector3) Vector3
Returns a vector equivalent to
directionreflected by the plane defined bynormal.See https://docs.unity3d.com/ScriptReference/Vector3.Reflect.html.
- static rotate_towards(current: Vector3, target: Vector3, max_radians: float, max_meters: float) Vector3
Returns a vector as close to
targetas possible while keeping the angle betweencurrentless than or equal tomax_radiansand its difference in magnitude less than or equal tomax_meters.See https://docs.unity3d.com/ScriptReference/Vector3.RotateTowards.html.
- static pairswise_scale(v: Vector3, u: Vector3) Vector3
Returns a vector equivalent to
Vector3(*[a * b for a,b in zip(v,u)])See https://docs.unity3d.com/ScriptReference/Vector3.Scale.html.
- static signed_angle(source: Vector3, destination: Vector3, axis: Vector3) float
Returns the angle in radians between
sourceanddestinationusingaxisandcross()to determine the sign.See https://docs.unity3d.com/ScriptReference/Vector3.SignedAngle.html.
- static slerp(v: Vector3, u: Vector3, t: float) Vector3
Returns the spherical interpolation between
vandubyt.See https://docs.unity3d.com/ScriptReference/Vector3.Slerp.html.
- static slerp_unclamped(v: Vector3, u: Vector3, t: float) Vector3
Returns the unclamped spherical interpolation between
vandubyt.See https://docs.unity3d.com/ScriptReference/Vector3.SlerpUnclamped.html.
- static euler_angles_from_rotation_axis(axis: Vector3) Vector3
Decomposes a rotation around an axis (with magnitude in radians) into three axis aligned rotations ordered z then x then y, known as euler angles.