unreal.Vector
¶
- class unreal.Vector(x=0.0, y=0.0, z=0.0)¶
Bases:
unreal.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
(float): [Read-Write] Xy
(float): [Read-Write] Yz
(float): [Read-Write] Z
- __add__(other)¶
Overloads:
Vector
Vector addition
- __eq__(other)¶
Overloads:
Vector
Returns true if vector A is equal to vector B (A == B)
- __iadd__(other)¶
Overloads:
Vector
Vector addition
- __imul__(other)¶
Overloads:
Vector
Element-wise Vector multiplication (Result = {A.x*B.x, A.y*B.y, A.z*B.z})float
Scales Vector A by B
- __isub__(other)¶
Overloads:
Vector
Vector subtraction
- __mul__(other)¶
Overloads:
Vector
Element-wise Vector multiplication (Result = {A.x*B.x, A.y*B.y, A.z*B.z})float
Scales Vector A by B
- __ne__(other)¶
Overloads:
Vector
Returns true if vector A is not equal to vector B (A != B)
- __neg__()¶
Negate a vector.
- __or__(other)¶
Overloads:
Vector
Returns the dot product of two 3d vectors - see http://mathworld.wolfram.com/DotProduct.html
- __sub__(other)¶
Overloads:
Vector
Vector subtraction
- __truediv__(other)¶
Overloads:
Vector
Element-wise Vector division (Result = {A.x/B.x, A.y/B.y, A.z/B.z})float
Vector divide by a float
- __xor__(other)¶
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_int(b) → Vector¶
Adds an integer to each component of a vector
- Parameters
b (int32) –
- Returns
- 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.
- 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.
- clamped_size_max(max) → Vector¶
Create a copy of this vector, with its maximum magnitude/size/length clamped to MaxSize.
- clamped_size_max2d(max) → Vector¶
Create a copy of this vector, with the maximum 2D magnitude/size/length clamped to MaxSize. Z is unchanged.
- cosine_angle2d(b) → float¶
Returns the cosine of the angle between this vector and another projected onto the XY plane (no Z).
- 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.
- distance2d_squared(v2) → float¶
Squared euclidean distance between two points in the XY plane (ignoring Z).
- divide(b=[1.0, 1.0, 1.0]) → Vector¶
Element-wise Vector division (Result = {A.x/B.x, A.y/B.y, A.z/B.z})
- dot(b) → float¶
Returns the dot product of two 3d vectors - see http://mathworld.wolfram.com/DotProduct.html
- 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() → float¶
Find the maximum absolute element (abs(X), abs(Y) or abs(Z)) of a vector
- Returns
- Return type
- get_abs_min() → float¶
Find the minimum absolute element (abs(X), abs(Y) or abs(Z)) of a vector
- Returns
- Return type
- 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.
- Returns
- Return type
- heading_angle() → float¶
Convert a direction vector into a ‘heading’ angle.
- Returns
‘Heading’ angle between +/-PI radians. 0 is pointing down +X.
- Return type
- interp_spring_to(target, spring_state, stiffness, critical_damping_factor, delta_time, mass=1.000000) -> (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) –
mass (float) – Multiplier that acts like mass on a spring
- 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.0001) → bool¶
Returns true if vector A is equal to vector B (A == B) within a specified error tolerance
- is_nearly_zero(tolerance=0.0001) → 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.0001) → bool¶
Returns true if vector A is not equal to vector B (A != B) within a specified error tolerance
- is_uniform(tolerance=0.0001) → bool¶
Checks whether all components of this vector are the same, within a tolerance.
- is_unit(squared_lenth_tolerance=0.0001) → 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
- length2d_squared() → float¶
Returns the squared length of the vector’s XY components.
- Returns
- Return type
- 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
- Returns
- 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.0001) → 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.0001) → 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.0) → 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 ‘FQuat::FindBetweenVectors(FVector::ForwardVector, YourVector)’ or ‘FQuat::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(box_extent) → 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 this axis and supplied angle (in degrees)
- subtract_int(b) → Vector¶
Subtracts an integer from each component of a vector
- Parameters
b (int32) –
- Returns
- 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
- transform() → Transform¶
Convert a vector to a transform. Uses vector as location
- Returns
- 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)
- Returns
- 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