.. Generated automatically by doc/tools/makerst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the Vector2.xml source instead. .. The source is found in doc/classes or modules//doc_classes. .. _class_Vector2: Vector2 ======= **Category:** Built-In Types Brief Description ----------------- Vector used for 2D math. Member Functions ---------------- +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`Vector2` **(** :ref:`float` x, :ref:`float` y **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`abs` **(** **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`angle` **(** **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`angle_to` **(** :ref:`Vector2` to **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`angle_to_point` **(** :ref:`Vector2` to **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`aspect` **(** **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`bounce` **(** :ref:`Vector2` n **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`ceil` **(** **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`clamped` **(** :ref:`float` length **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`cross` **(** :ref:`Vector2` with **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`cubic_interpolate` **(** :ref:`Vector2` b, :ref:`Vector2` pre_a, :ref:`Vector2` post_b, :ref:`float` t **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`distance_squared_to` **(** :ref:`Vector2` to **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`distance_to` **(** :ref:`Vector2` to **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`dot` **(** :ref:`Vector2` with **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`floor` **(** **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_normalized` **(** **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`length` **(** **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`length_squared` **(** **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`linear_interpolate` **(** :ref:`Vector2` b, :ref:`float` t **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`normalized` **(** **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`reflect` **(** :ref:`Vector2` n **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`rotated` **(** :ref:`float` phi **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`round` **(** **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`slerp` **(** :ref:`Vector2` b, :ref:`float` t **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`slide` **(** :ref:`Vector2` n **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`snapped` **(** :ref:`Vector2` by **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`tangent` **(** **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Member Variables ---------------- .. _class_Vector2_x: - :ref:`float` **x** - The vector's x component. .. _class_Vector2_y: - :ref:`float` **y** - The vector's y component. Description ----------- 2-element structure that can be used to represent positions in 2d space or any other pair of numeric values. Member Function Description --------------------------- .. _class_Vector2_Vector2: - :ref:`Vector2` **Vector2** **(** :ref:`float` x, :ref:`float` y **)** Constructs a new Vector2 from the given x and y. .. _class_Vector2_abs: - :ref:`Vector2` **abs** **(** **)** Returns a new vector with all components in absolute values (i.e. positive). .. _class_Vector2_angle: - :ref:`float` **angle** **(** **)** Returns the vector's angle in radians with respect to the x-axis, or ``(1, 0)`` vector. Equivalent to the result of atan2 when called with the vector's x and y as parameters: ``atan2(x, y)``. .. _class_Vector2_angle_to: - :ref:`float` **angle_to** **(** :ref:`Vector2` to **)** Returns the angle in radians between the two vectors. .. _class_Vector2_angle_to_point: - :ref:`float` **angle_to_point** **(** :ref:`Vector2` to **)** Returns the angle in radians between the line connecting the two points and the x coordinate. .. _class_Vector2_aspect: - :ref:`float` **aspect** **(** **)** Returns the ratio of x to y. .. _class_Vector2_bounce: - :ref:`Vector2` **bounce** **(** :ref:`Vector2` n **)** Returns the vector "bounced off" from a plane defined by the given normal. .. _class_Vector2_ceil: - :ref:`Vector2` **ceil** **(** **)** .. _class_Vector2_clamped: - :ref:`Vector2` **clamped** **(** :ref:`float` length **)** Returns the vector with a maximum length. .. _class_Vector2_cross: - :ref:`float` **cross** **(** :ref:`Vector2` with **)** Returns the 2 dimensional analog of the cross product with the given vector. .. _class_Vector2_cubic_interpolate: - :ref:`Vector2` **cubic_interpolate** **(** :ref:`Vector2` b, :ref:`Vector2` pre_a, :ref:`Vector2` post_b, :ref:`float` t **)** Cubicly interpolates between this vector and ``b`` using ``pre_a`` and ``post_b`` as handles, and returns the result at position ``t``. ``t`` is in the range of ``0.0 - 1.0``, or a percentage of how far along the interpolation is. .. _class_Vector2_distance_squared_to: - :ref:`float` **distance_squared_to** **(** :ref:`Vector2` to **)** Returns the squared distance to vector ``b``. Prefer this function over :ref:`distance_to` if you need to sort vectors or need the squared distance for some formula. .. _class_Vector2_distance_to: - :ref:`float` **distance_to** **(** :ref:`Vector2` to **)** Returns the distance to vector ``b``. .. _class_Vector2_dot: - :ref:`float` **dot** **(** :ref:`Vector2` with **)** Returns the dot product with vector ``b``. .. _class_Vector2_floor: - :ref:`Vector2` **floor** **(** **)** Remove the fractional part of x and y. .. _class_Vector2_is_normalized: - :ref:`bool` **is_normalized** **(** **)** Returns ``true`` if the vector is normalized. .. _class_Vector2_length: - :ref:`float` **length** **(** **)** Returns the vector's length. .. _class_Vector2_length_squared: - :ref:`float` **length_squared** **(** **)** Returns the vector's length squared. Prefer this function over :ref:`length` if you need to sort vectors or need the squared length for some formula. .. _class_Vector2_linear_interpolate: - :ref:`Vector2` **linear_interpolate** **(** :ref:`Vector2` b, :ref:`float` t **)** Returns the result of the linear interpolation between this vector and ``b`` by amount ``t``. ``t`` is in the range of ``0.0 - 1.0``, a percentage of how far along the interpolation is. .. _class_Vector2_normalized: - :ref:`Vector2` **normalized** **(** **)** Returns the vector scaled to unit length. Equivalent to ``v / v.length()``. .. _class_Vector2_reflect: - :ref:`Vector2` **reflect** **(** :ref:`Vector2` n **)** Returns the vector reflected from a plane defined by the given normal. .. _class_Vector2_rotated: - :ref:`Vector2` **rotated** **(** :ref:`float` phi **)** Returns the vector rotated by ``phi`` radians. .. _class_Vector2_round: - :ref:`Vector2` **round** **(** **)** .. _class_Vector2_slerp: - :ref:`Vector2` **slerp** **(** :ref:`Vector2` b, :ref:`float` t **)** Returns the result of SLERP between this vector and "b", by amount "t". "t" should be a float of 0.0-1.0, a percentage of how far along the interpolation is. Both vectors need to be normalized. .. _class_Vector2_slide: - :ref:`Vector2` **slide** **(** :ref:`Vector2` n **)** Returns the component of the vector along a plane defined by the given normal. .. _class_Vector2_snapped: - :ref:`Vector2` **snapped** **(** :ref:`Vector2` by **)** Returns the vector snapped to a grid with the given size. .. _class_Vector2_tangent: - :ref:`Vector2` **tangent** **(** **)** Returns a perpendicular vector.