:right-sidebar: True Vec4 =================================================================== .. currentmodule:: gi.repository.Graphene .. class:: Vec4(*args, **kwargs) :no-contents-entry: A structure capable of holding a vector with four dimensions: x, y, z, and w. The contents of the :obj:`~gi.repository.Graphene.Vec4` structure are private and should never be accessed directly. Constructors ------------ .. rst-class:: interim-class .. class:: Vec4 :no-index: .. classmethod:: alloc() -> ~gi.repository.Graphene.Vec4 Allocates a new :obj:`~gi.repository.Graphene.Vec4` structure. The contents of the returned structure are undefined. Use :func:`~gi.repository.Graphene.Vec4.init` to initialize the vector. .. versionadded:: 1.0 Methods ------- .. rst-class:: interim-class .. class:: Vec4 :no-index: .. method:: add(b: ~gi.repository.Graphene.Vec4) -> ~gi.repository.Graphene.Vec4 Adds each component of the two given vectors. .. versionadded:: 1.0 :param b: a :obj:`~gi.repository.Graphene.Vec4` .. method:: divide(b: ~gi.repository.Graphene.Vec4) -> ~gi.repository.Graphene.Vec4 Divides each component of the first operand ``a`` by the corresponding component of the second operand ``b``\, and places the results into the vector ``res``\. .. versionadded:: 1.0 :param b: a :obj:`~gi.repository.Graphene.Vec4` .. method:: dot(b: ~gi.repository.Graphene.Vec4) -> float Computes the dot product of the two given vectors. .. versionadded:: 1.0 :param b: a :obj:`~gi.repository.Graphene.Vec4` .. method:: equal(v2: ~gi.repository.Graphene.Vec4) -> bool Checks whether the two given :obj:`~gi.repository.Graphene.Vec4` are equal. .. versionadded:: 1.2 :param v2: a :obj:`~gi.repository.Graphene.Vec4` .. method:: free() -> None Frees the resources allocated by ``v`` .. versionadded:: 1.0 .. method:: get_w() -> float Retrieves the value of the fourth component of the given :obj:`~gi.repository.Graphene.Vec4`\. .. versionadded:: 1.0 .. method:: get_x() -> float Retrieves the value of the first component of the given :obj:`~gi.repository.Graphene.Vec4`\. .. versionadded:: 1.0 .. method:: get_xy() -> ~gi.repository.Graphene.Vec2 Creates a :obj:`~gi.repository.Graphene.Vec2` that contains the first two components of the given :obj:`~gi.repository.Graphene.Vec4`\. .. versionadded:: 1.0 .. method:: get_xyz() -> ~gi.repository.Graphene.Vec3 Creates a :obj:`~gi.repository.Graphene.Vec3` that contains the first three components of the given :obj:`~gi.repository.Graphene.Vec4`\. .. versionadded:: 1.0 .. method:: get_y() -> float Retrieves the value of the second component of the given :obj:`~gi.repository.Graphene.Vec4`\. .. versionadded:: 1.0 .. method:: get_z() -> float Retrieves the value of the third component of the given :obj:`~gi.repository.Graphene.Vec4`\. .. versionadded:: 1.0 .. method:: init(x: float, y: float, z: float, w: float) -> ~gi.repository.Graphene.Vec4 Initializes a :obj:`~gi.repository.Graphene.Vec4` using the given values. This function can be called multiple times. .. versionadded:: 1.0 :param x: the X field of the vector :param y: the Y field of the vector :param z: the Z field of the vector :param w: the W field of the vector .. method:: init_from_float(src: list[float]) -> ~gi.repository.Graphene.Vec4 Initializes a :obj:`~gi.repository.Graphene.Vec4` with the values inside the given array. .. versionadded:: 1.0 :param src: an array of four floating point values .. method:: init_from_vec2(src: ~gi.repository.Graphene.Vec2, z: float, w: float) -> ~gi.repository.Graphene.Vec4 Initializes a :obj:`~gi.repository.Graphene.Vec4` using the components of a :obj:`~gi.repository.Graphene.Vec2` and the values of ``z`` and ``w``\. .. versionadded:: 1.0 :param src: a :obj:`~gi.repository.Graphene.Vec2` :param z: the value for the third component of ``v`` :param w: the value for the fourth component of ``v`` .. method:: init_from_vec3(src: ~gi.repository.Graphene.Vec3, w: float) -> ~gi.repository.Graphene.Vec4 Initializes a :obj:`~gi.repository.Graphene.Vec4` using the components of a :obj:`~gi.repository.Graphene.Vec3` and the value of ``w``\. .. versionadded:: 1.0 :param src: a :obj:`~gi.repository.Graphene.Vec3` :param w: the value for the fourth component of ``v`` .. method:: init_from_vec4(src: ~gi.repository.Graphene.Vec4) -> ~gi.repository.Graphene.Vec4 Initializes a :obj:`~gi.repository.Graphene.Vec4` using the components of another :obj:`~gi.repository.Graphene.Vec4`\. .. versionadded:: 1.0 :param src: a :obj:`~gi.repository.Graphene.Vec4` .. method:: interpolate(v2: ~gi.repository.Graphene.Vec4, factor: float) -> ~gi.repository.Graphene.Vec4 Linearly interpolates ``v1`` and ``v2`` using the given ``factor``\. .. versionadded:: 1.10 :param v2: a :obj:`~gi.repository.Graphene.Vec4` :param factor: the interpolation factor .. method:: length() -> float Computes the length of the given :obj:`~gi.repository.Graphene.Vec4`\. .. versionadded:: 1.0 .. method:: max(b: ~gi.repository.Graphene.Vec4) -> ~gi.repository.Graphene.Vec4 Compares each component of the two given vectors and creates a vector that contains the maximum values. .. versionadded:: 1.0 :param b: a :obj:`~gi.repository.Graphene.Vec4` .. method:: min(b: ~gi.repository.Graphene.Vec4) -> ~gi.repository.Graphene.Vec4 Compares each component of the two given vectors and creates a vector that contains the minimum values. .. versionadded:: 1.0 :param b: a :obj:`~gi.repository.Graphene.Vec4` .. method:: multiply(b: ~gi.repository.Graphene.Vec4) -> ~gi.repository.Graphene.Vec4 Multiplies each component of the two given vectors. .. versionadded:: 1.0 :param b: a :obj:`~gi.repository.Graphene.Vec4` .. method:: near(v2: ~gi.repository.Graphene.Vec4, epsilon: float) -> bool Compares the two given :obj:`~gi.repository.Graphene.Vec4` vectors and checks whether their values are within the given ``epsilon``\. .. versionadded:: 1.2 :param v2: a :obj:`~gi.repository.Graphene.Vec4` :param epsilon: the threshold between the two vectors .. method:: negate() -> ~gi.repository.Graphene.Vec4 Negates the given :obj:`~gi.repository.Graphene.Vec4`\. .. versionadded:: 1.2 .. method:: normalize() -> ~gi.repository.Graphene.Vec4 Normalizes the given :obj:`~gi.repository.Graphene.Vec4`\. .. versionadded:: 1.0 .. classmethod:: one() -> ~gi.repository.Graphene.Vec4 Retrieves a pointer to a :obj:`~gi.repository.Graphene.Vec4` with all its components set to 1. .. versionadded:: 1.0 .. method:: scale(factor: float) -> ~gi.repository.Graphene.Vec4 Multiplies all components of the given vector with the given scalar ``factor``\. .. versionadded:: 1.2 :param factor: the scalar factor .. method:: subtract(b: ~gi.repository.Graphene.Vec4) -> ~gi.repository.Graphene.Vec4 Subtracts from each component of the first operand ``a`` the corresponding component of the second operand ``b`` and places each result into the components of ``res``\. .. versionadded:: 1.0 :param b: a :obj:`~gi.repository.Graphene.Vec4` .. method:: to_float() -> list[float] Stores the components of the given :obj:`~gi.repository.Graphene.Vec4` into an array of floating point values. .. versionadded:: 1.0 .. classmethod:: w_axis() -> ~gi.repository.Graphene.Vec4 Retrieves a pointer to a :obj:`~gi.repository.Graphene.Vec4` with its components set to (0, 0, 0, 1). .. versionadded:: 1.0 .. classmethod:: x_axis() -> ~gi.repository.Graphene.Vec4 Retrieves a pointer to a :obj:`~gi.repository.Graphene.Vec4` with its components set to (1, 0, 0, 0). .. versionadded:: 1.0 .. classmethod:: y_axis() -> ~gi.repository.Graphene.Vec4 Retrieves a pointer to a :obj:`~gi.repository.Graphene.Vec4` with its components set to (0, 1, 0, 0). .. versionadded:: 1.0 .. classmethod:: z_axis() -> ~gi.repository.Graphene.Vec4 Retrieves a pointer to a :obj:`~gi.repository.Graphene.Vec4` with its components set to (0, 0, 1, 0). .. versionadded:: 1.0 .. classmethod:: zero() -> ~gi.repository.Graphene.Vec4 Retrieves a pointer to a :obj:`~gi.repository.Graphene.Vec4` with all its components set to 0. .. versionadded:: 1.0 Fields ------ .. rst-class:: interim-class .. class:: Vec4 :no-index: .. attribute:: value