unreal.Vector2D
¶
-
class
unreal.
Vector2D
(x=0.0, y=0.0)¶ Bases:
unreal.StructBase
A vector in 2-D space composed of components (X, Y) with floating point precision. The full C++ class is located here: EngineSourceRuntimeCorePublicMathVector2D.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] Y
-
UNIT45_DEG
= None¶ //en.wikipedia.org/wiki/Unit_vector
- Type
(Vector2D)
- Type
2D unit vector constant along the 45 degree angle or symmetrical positive axes (sqrt(5),sqrt(5)) or (707,707) https
-
__add__
(other)¶ Overloads:
Vector2D
Returns addition of Vector A and Vector B (A + B)float
Returns Vector A added by B
-
__eq__
(other)¶ Overloads:
Vector2D
Returns true if vector A is equal to vector B (A == B)
-
__iadd__
(other)¶ Overloads:
Vector2D
Returns addition of Vector A and Vector B (A + B)float
Returns Vector A added by B
-
__imul__
(other)¶ Overloads:
Vector2D
Element-wise Vector multiplication (Result = {A.x*B.x, A.y*B.y})float
Returns Vector A scaled by B
-
__isub__
(other)¶ Overloads:
Vector2D
Returns subtraction of Vector B from Vector A (A - B)float
Returns Vector A subtracted by B
-
__mul__
(other)¶ Overloads:
Vector2D
Element-wise Vector multiplication (Result = {A.x*B.x, A.y*B.y})float
Returns Vector A scaled by B
-
__ne__
(other)¶ Overloads:
Vector2D
Returns true if vector2D A is not equal to vector2D B (A != B) within a specified error tolerance
-
__neg__
()¶ Gets a negated copy of the vector.
-
__or__
(other)¶ Overloads:
Vector2D
Returns the dot product of two 2d vectors - see http://mathworld.wolfram.com/DotProduct.html
-
__sub__
(other)¶ Overloads:
Vector2D
Returns subtraction of Vector B from Vector A (A - B)float
Returns Vector A subtracted by B
-
__truediv__
(other)¶ Overloads:
Vector2D
Element-wise Vector divide (Result = {A.x/B.x, A.y/B.y})float
Returns Vector A divided by B
-
__xor__
(other)¶ Overloads:
Vector2D
Returns the cross product of two 2d vectors - see http://mathworld.wolfram.com/CrossProduct.html
-
clamped_axes
(min_axis_val, max_axis_val) → Vector2D¶ Creates a copy of this vector with both axes clamped to the given range.
-
cross
(b) → float¶ Returns the cross product of two 2d vectors - see http://mathworld.wolfram.com/CrossProduct.html
-
dot
(b) → float¶ Returns the dot product of two 2d vectors - see http://mathworld.wolfram.com/DotProduct.html
-
get_abs
() → Vector2D¶ 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¶ Get the maximum absolute value of the vector’s components.
- Returns
The maximum absolute value of the vector’s components.
- Return type
-
get_max
() → float¶ Get the maximum value of the vector’s components.
- Returns
The maximum value of the vector’s components.
- Return type
-
get_min
() → float¶ Get the minimum value of the vector’s components.
- Returns
The minimum value of the vector’s components.
- Return type
-
interp_to
(target, delta_time, interp_speed) → Vector2D¶ 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) → Vector2D¶ Tries to reach Target at a constant rate.
-
is_near_equal
(b, error_tolerance=0.0001) → bool¶ Returns true if vector2D A is equal to vector2D 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_not_near_equal
(b, error_tolerance=0.0001) → bool¶ Returns true if vector2D A is not equal to vector2D B (A != B) within a specified error 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
-
normal
(tolerance=0.0) → Vector2D¶ Gets a normalized copy of the vector, checking it is safe to do so based on the length. Returns zero vector if vector length is too small to safely normalize.
-
normalize
(tolerance=0.0) → None¶ Normalize this vector in-place if it is large enough, set it to (0,0) otherwise. NormalSafe2D():
- Parameters
tolerance (float) – Minimum squared length of vector for normalization.
-
not_equal
(b) → bool¶ Returns true if vector2D A is not equal to vector2D B (A != B) within a specified error tolerance
-
spherical_to_unit_cartesian
() → Vector¶ Converts spherical coordinates on the unit sphere into a Cartesian unit length vector.
- Returns
- Return type
-
to_direction_and_length
() -> (out_dir=Vector2D, out_length=float)¶ Util to convert this vector into a unit direction vector and its original length.
- Returns
out_dir (Vector2D): Reference passed in to store unit direction vector.
out_length (float): Reference passed in to store length of the vector.
- Return type
tuple
-
to_rounded
() → Vector2D¶ Get this vector as a vector where each component has been rounded to the nearest int.
- Returns
New FVector2D from this vector that is rounded.
- Return type
-
to_sign
() → Vector2D¶ 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
A copy of the vector with each component set to +1 or -1
- Return type