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 Vector3 is an immutable object, so it’s x, y, and z properties cannot be changed, and all of its methods return new Vector3 s without modifying the original.

In addition to the methods documented here, Vector3 also supports infix operators such as +, - between vectors, * between a vector and a float when the vector occurs on the left, and unary - equivalent to multiplying by -1. Vector3 also implements the __getitem__ method for indices 0, 1, 2. So you can access the x, y, z components of a vector v as v[0], v[1], and v[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 v and u.

See https://docs.unity3d.com/ScriptReference/Vector3-operator_multiply.html.

static scale(v: Vector3, s: float) Vector3

Returns a vector equivalent to v scaled by s.

See https://docs.unity3d.com/ScriptReference/Vector3-operator_multiply.html.

static cross(v: Vector3, u: Vector3) Vector3

Returns the cross product of v and u.

See https://docs.unity3d.com/ScriptReference/Vector3.Cross.html.

static project_onto_vector(original: Vector3, normal: Vector3) Vector3

Returns the projection of original onto normal.

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_project onto plane_normal.

See https://docs.unity3d.com/ScriptReference/Vector3.ProjectOnPlane.html.

static lerp(start: Vector3, end: Vector3, t: float) Vector3

Returns a vector which is t percent of the way between start and end.

See https://docs.unity3d.com/ScriptReference/Vector3.Lerp.html.

static angle(source: Vector3, destination: Vector3) float

Returns the angle in radians between source and destination.

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 source and destination.

See https://docs.unity3d.com/ScriptReference/Vector3.Angle.html.

static clamp_magnitude(v: Vector3, length: float) Vector3

Returns a vector in the direction of v with magnitude of max(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 t percent of the way between start and end. If t is less than 0 or greater than 1, 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 target as possible while being at most max_distance far from current.

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. normal will stay pointed in the same direction, but the other argument(s) may be redirected to be orthoganal to each other. If binormal is supplied, a third result will be in the returned tuple, otherwise it will be left as None.

See https://docs.unity3d.com/ScriptReference/Vector3.OrthoNormalize.html.

static reflect(normal: Vector3, direction: Vector3) Vector3

Returns a vector equivalent to direction reflected by the plane defined by normal.

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 target as possible while keeping the angle between current less than or equal to max_radians and its difference in magnitude less than or equal to max_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 source and destination using axis and cross() 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 v and u by t.

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 v and u by t.

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.

static rotation_axis_from_euler_angles(eulers: Vector3) Vector3

Composes three rotations in the form of euler angles into a single axis of rotation whose magnitude is the magnitude of the rotation in radians.

compose_rotations(r: Vector3) Vector3

compose rotation axes, first q and then r into a new rotation axis.