unreal.Vector
¶
- class unreal.Vector(x: float = 0.0, y: float = 0.0, z: float = 0.0)¶
Bases:
StructBase
A point or direction FVector in 3d space. note: The full C++ class is located here: EngineSourceRuntimeCorePublicMathVector.h
C++ Source:
Module: CoreUObject
File: NoExportTypes.h
Editor Properties: (see get_editor_property/set_editor_property)
x
(double): [Read-Write]y
(double): [Read-Write]z
(double): [Read-Write]
- __eq__(other: object) bool ¶
Overloads:
Vector
Returns true if vector A is equal to vector B (A == B)
- __imul__(other: Vector) None ¶
Overloads:
Vector
Element-wise Vector multiplication (Result = {A.x*B.x, A.y*B.y, A.z*B.z})double
Scales Vector A by B
- __mul__(other: Vector) None ¶
Overloads:
Vector
Element-wise Vector multiplication (Result = {A.x*B.x, A.y*B.y, A.z*B.z})double
Scales Vector A by B
- __ne__(other: object) bool ¶
Overloads:
Vector
Returns true if vector A is not equal to vector B (A != B)
- __or__(other: Vector) None ¶
Overloads:
Vector
Returns the dot product of two 3d vectors - see http://mathworld.wolfram.com/DotProduct.html
- __truediv__(other: Vector) None ¶
Overloads:
Vector
Element-wise Vector division (Result = {A.x/B.x, A.y/B.y, A.z/B.z})double
Vector divide by a float
- __xor__(other: Vector) None ¶
Overloads:
Vector
Returns the cross product of two 3d vectors - see http://mathworld.wolfram.com/CrossProduct.html
- add_bounded(add_vect, radius) None ¶
Add a vector to this and clamp the result to an axis aligned cube centered at the origin.
- add_float(b) Vector ¶
Adds a float to each component of a vector
- Parameters:
b (double) –
- Return type:
- add_int(b) Vector ¶
Adds an integer to each component of a vector
- Parameters:
b (int32) –
- Return type:
- assign(vector) None ¶
Assign the values of the supplied vector.
- Parameters:
vector (Vector) – Vector to copy values from.
- bounded_to_box(box_min, box_max) Vector ¶
Get a copy of this vector, clamped inside of the specified axis aligned cube.
- bounded_to_cube(radius) Vector ¶
Get a copy of this vector, clamped inside of an axis aligned cube centered at the origin.
- clamped_size(min, max) Vector ¶
Create a copy of this vector, with its magnitude/size/length clamped between Min and Max.
- Parameters:
min (double) –
max (double) –
- Return type:
- clamped_size2d(min, max) Vector ¶
Create a copy of this vector, with the 2D magnitude/size/length clamped between Min and Max. Z is unchanged.
- Parameters:
min (double) –
max (double) –
- Return type:
- clamped_size_max(max) Vector ¶
Create a copy of this vector, with its maximum magnitude/size/length clamped to MaxSize.
- Parameters:
max (double) –
- Return type:
- clamped_size_max2d(max) Vector ¶
Create a copy of this vector, with the maximum 2D magnitude/size/length clamped to MaxSize. Z is unchanged.
- Parameters:
max (double) –
- Return type:
- cosine_angle2d(b) double ¶
Returns the cosine of the angle between this vector and another projected onto the XY plane (no Z).
- Parameters:
b (Vector) – the other vector to find the 2D cosine of the angle with.
- Returns:
The cosine.
- Return type:
double
- cross(b) Vector ¶
Returns the cross product of two 3d vectors - see http://mathworld.wolfram.com/CrossProduct.html
- direction_unit_to(to) Vector ¶
Find the unit direction vector from one position to another or (0,0,0) if positions are the same.
- distance(v2) double ¶
Distance between two points.
- Parameters:
v2 (Vector) – The second point.
- Returns:
The distance between two points.
- Return type:
double
- distance2d(v2) double ¶
Euclidean distance between two points in the XY plane (ignoring Z).
- Parameters:
v2 (Vector) – The second point.
- Returns:
The distance between two points in the XY plane.
- Return type:
double
- distance2d_squared(v2) double ¶
Squared euclidean distance between two points in the XY plane (ignoring Z).
- Parameters:
v2 (Vector) – The second point.
- Returns:
The distance between two points in the XY plane.
- Return type:
double
- distance_squared(v2) double ¶
Squared distance between two points.
- Parameters:
v2 (Vector) – The second point.
- Returns:
The squared distance between two points.
- Return type:
double
- divide(b=[1.000000, 1.000000, 1.000000]) Vector ¶
Element-wise Vector division (Result = {A.x/B.x, A.y/B.y, A.z/B.z})
- dot(b) double ¶
Returns the dot product of two 3d vectors - see http://mathworld.wolfram.com/DotProduct.html
- Parameters:
b (Vector) –
- Return type:
double
- find_quat_between_normals(end_normal) Quat ¶
Generates the ‘smallest’ (geodesic) rotation around a sphere between two normals (assumed to be unit length).
- find_quat_between_vectors(end) Quat ¶
Generates the ‘smallest’ (geodesic) rotation around a sphere between two vectors of arbitrary length.
- get_abs() Vector ¶
Get a copy of this vector with absolute value of each component.
- Returns:
A copy of this vector with absolute value of each component.
- Return type:
- get_abs_max() double ¶
Find the maximum absolute element (abs(X), abs(Y) or abs(Z)) of a vector
- Return type:
double
- get_abs_min() double ¶
Find the minimum absolute element (abs(X), abs(Y) or abs(Z)) of a vector
- Return type:
double
- get_max_element() double ¶
Find the maximum element (X, Y or Z) of a vector
- Return type:
double
- get_min_element() double ¶
Find the minimum element (X, Y or Z) of a vector
- Return type:
double
- get_projection() Vector ¶
Projects 2D components of vector based on Z.
- Returns:
Projected version of vector based on Z.
- Return type:
- get_sign_vector() Vector ¶
Get a copy of the vector as sign only. Each component is set to +1 or -1, with the sign of zero treated as +1.
- Return type:
- heading_angle() double ¶
Convert a direction vector into a ‘heading’ angle.
- Returns:
‘Heading’ angle between +/-PI radians. 0 is pointing down +X.
- Return type:
double
- interp_spring_to(target, spring_state, stiffness, critical_damping_factor, delta_time, mass=1.000000, target_velocity_amount=1.000000, clamp=False, min_value=[-1.000000, -1.000000, -1.000000], max_value=[1.000000, 1.000000, 1.000000], initialize_from_target=False) -> (Vector, spring_state=VectorSpringState)¶
Uses a simple spring model to interpolate a vector from Current to Target.
- Parameters:
target (Vector) – Target value
spring_state (VectorSpringState) – Data related to spring model (velocity, error, etc..) - Create a unique variable per spring
stiffness (float) – How stiff the spring model is (more stiffness means more oscillation around the target value)
critical_damping_factor (float) – How much damping to apply to the spring (0 means no damping, 1 means critically damped which means no oscillation)
delta_time (float) – Time difference since the last update
mass (float) – Multiplier that acts like mass on a spring
target_velocity_amount (float) – If 1 then the target velocity will be calculated and used, which results following the target more closely/without lag. Values down to zero (recommended when using this to smooth data) will progressively disable this effect.
clamp (bool) – Whether to use the Min/Max values to clamp the motion
min_value (Vector) – Clamps the minimum output value and cancels the velocity if it reaches this limit
max_value (Vector) – Clamps the maximum output value and cancels the velocity if it reaches this limit
initialize_from_target (bool) – If set then the current value will be set from the target on the first update
- Returns:
spring_state (VectorSpringState): Data related to spring model (velocity, error, etc..) - Create a unique variable per spring
- Return type:
- interp_to(target, delta_time, interp_speed) Vector ¶
Tries to reach Target based on distance from Current position, giving a nice smooth feeling when tracking a position.
- interp_to_constant(target, delta_time, interp_speed) Vector ¶
Tries to reach Target at a constant rate.
- is_nan() bool ¶
Determines if any component is not a number (NAN)
- Returns:
true if one or more components is NAN, otherwise false.
- Return type:
- is_near_equal(b, error_tolerance=0.000100) bool ¶
Returns true if vector A is equal to vector B (A == B) within a specified error tolerance
- is_nearly_zero(tolerance=0.000100) bool ¶
Checks whether vector is near to zero within a specified tolerance.
- is_normal() bool ¶
Determines if vector is normalized / unit (length 1).
- Returns:
true if normalized, false otherwise.
- Return type:
- is_not_near_equal(b, error_tolerance=0.000100) bool ¶
Returns true if vector A is not equal to vector B (A != B) within a specified error tolerance
- is_uniform(tolerance=0.000100) bool ¶
Checks whether all components of this vector are the same, within a tolerance.
- is_unit(squared_lenth_tolerance=0.000100) bool ¶
Determines if vector is normalized / unit (length 1) within specified squared tolerance.
- is_zero() bool ¶
Checks whether all components of the vector are exactly zero.
- Returns:
true if vector is exactly zero, otherwise false.
- Return type:
- length() double ¶
Returns the length of the vector
- Return type:
double
- length2d() double ¶
Returns the length of the vector’s XY components.
- Return type:
double
- length2d_squared() double ¶
Returns the squared length of the vector’s XY components.
- Return type:
double
- length_squared() double ¶
Returns the squared length of the vector
- Return type:
double
- lerp_to(b, alpha) Vector ¶
Linearly interpolates between A and B based on Alpha (100% of A when Alpha=0 and 100% of B when Alpha=1)
- linear_color() LinearColor ¶
Converts a vector to LinearColor
- Return type:
- mirror_by_vector(surface_normal) Vector ¶
Given a direction vector and a surface normal, returns the vector reflected across the surface normal. Produces a result like shining a laser at a mirror!
- normal(tolerance=0.000100) Vector ¶
Gets a normalized unit copy of the vector, ensuring it is safe to do so based on the length. Returns zero vector if vector length is too small to safely normalize.
- normal2d(tolerance=0.000100) Vector ¶
Gets a normalized unit copy of the 2D components of the vector, ensuring it is safe to do so. Z is set to zero. Returns zero vector if vector length is too small to normalize.
- normal_unsafe() Vector ¶
Calculates normalized unit version of vector without checking for zero length.
- Returns:
Normalized version of vector.
- Return type:
- normalize(tolerance=0.000000) None ¶
Normalize this vector in-place if it is large enough or set it to (0,0,0) otherwise.
- Parameters:
tolerance (float) – Minimum squared length of vector for normalization.
- project_on_to(target) Vector ¶
Projects one vector (V) onto another (Target) and returns the projected vector. If Target is nearly zero in length, returns the zero vector.
- project_on_to_normal(normal) Vector ¶
Gets a copy of this vector projected onto the input vector, which is assumed to be unit length.
- project_on_to_plane(plane_normal) Vector ¶
Projects a vector onto a plane defined by a normalized vector (PlaneNormal).
- project_point_on_to_plane(plane_base, plane_normal) Vector ¶
Projects/snaps a point onto a plane defined by a point on the plane and a plane normal.
- quaternion() Quat ¶
Return the Quaternion orientation corresponding to the direction in which the vector points. Similar to the FRotator version, returns a result without roll such that it preserves the up vector. note: If you don’t care about preserving the up vector and just want the most direct rotation, you can use the faster ‘FindBetweenVectors(ForwardVector, YourVector)’ or ‘FindBetweenNormals(…)’ if you know the vector is of unit length.
- Returns:
Quaternion from the Vector’s direction, without any roll.
- Return type:
- random_point_in_box_extents(half_size) Vector ¶
Returns a random point within the specified bounding box using the first vector as an origin and the second as the box extents.
- reciprocal() Vector ¶
Gets the reciprocal of this vector, avoiding division by zero. Zero components are set to BIG_NUMBER.
- Returns:
Reciprocal of this vector.
- Return type:
- rotate_angle_axis(angle_deg, axis) Vector ¶
Returns result of vector A rotated by AngleDeg around Axis
- rotator() Rotator ¶
Return the FRotator orientation corresponding to the direction in which the vector points. Sets Yaw and Pitch to the proper numbers, and sets Roll to zero because the roll can’t be determined from a vector.
- Returns:
FRotator from the Vector’s direction, without any roll.
- Return type:
- rotator_from_axis_and_angle(angle) Rotator ¶
Create a rotation from an axis and supplied angle (in degrees)
- set(x, y, z) None ¶
Set the values of the vector directly.
- Parameters:
x (double) –
y (double) –
z (double) –
- slerp_normals(normal_b, alpha) Vector ¶
Interpolate from normalized vector A to normalized vector B along a spherical path.
- slerp_vectors(direction, alpha) Vector ¶
Interpolate from a vector to the direction of another vector along a spherical path.
- subtract_float(b) Vector ¶
Subtracts a float from each component of a vector
- Parameters:
b (double) –
- Return type:
- subtract_int(b) Vector ¶
Subtracts an integer from each component of a vector
- Parameters:
b (int32) –
- Return type:
- to_degrees() Vector ¶
Converts a vector containing radian values to a vector containing degree values.
- Returns:
Vector containing degree values
- Return type:
- to_radians() Vector ¶
Converts a vector containing degree values to a vector containing radian values.
- Returns:
Vector containing radian values
- Return type:
- truncated() IntVector ¶
Rounds A to an integer with truncation towards zero for each element in a vector. (e.g. -1.7 truncated to -1, 2.8 truncated to 2)
- Return type:
- unit_cartesian_to_spherical() Vector2D ¶
Converts a Cartesian unit vector into spherical coordinates on the unit sphere.
- Returns:
Output Theta will be in the range [0, PI], and output Phi will be in the range [-PI, PI].
- Return type:
- unwind_euler() None ¶
When this vector contains Euler angles (degrees), ensure that angles are between +/-180