:right-sidebar: True Vec3 =================================================================== .. currentmodule:: gi.repository.Graphene .. class:: Vec3(*args, **kwargs) :no-contents-entry: A structure capable of holding a vector with three dimensions: x, y, and z. The contents of the :obj:`~gi.repository.Graphene.Vec3` structure are private and should never be accessed directly. Constructors ------------ .. rst-class:: interim-class .. class:: Vec3 :no-index: .. classmethod:: alloc() -> ~gi.repository.Graphene.Vec3 Allocates a new :obj:`~gi.repository.Graphene.Vec3` structure. The contents of the returned structure are undefined. Use :func:`~gi.repository.Graphene.Vec3.init` to initialize the vector. .. versionadded:: 1.0 Methods ------- .. rst-class:: interim-class .. class:: Vec3 :no-index: .. method:: add(b: ~gi.repository.Graphene.Vec3) -> ~gi.repository.Graphene.Vec3 Adds each component of the two given vectors. .. versionadded:: 1.0 :param b: a :obj:`~gi.repository.Graphene.Vec3` .. method:: cross(b: ~gi.repository.Graphene.Vec3) -> ~gi.repository.Graphene.Vec3 Computes the cross product of the two given vectors. .. versionadded:: 1.0 :param b: a :obj:`~gi.repository.Graphene.Vec3` .. method:: divide(b: ~gi.repository.Graphene.Vec3) -> ~gi.repository.Graphene.Vec3 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.Vec3` .. method:: dot(b: ~gi.repository.Graphene.Vec3) -> float Computes the dot product of the two given vectors. .. versionadded:: 1.0 :param b: a :obj:`~gi.repository.Graphene.Vec3` .. method:: equal(v2: ~gi.repository.Graphene.Vec3) -> bool Checks whether the two given :obj:`~gi.repository.Graphene.Vec3` are equal. .. versionadded:: 1.2 :param v2: a :obj:`~gi.repository.Graphene.Vec3` .. method:: free() -> None Frees the resources allocated by ``v`` .. versionadded:: 1.0 .. method:: get_x() -> float Retrieves the first component of the given vector ``v``\. .. versionadded:: 1.0 .. method:: get_xy() -> ~gi.repository.Graphene.Vec2 Creates a :obj:`~gi.repository.Graphene.Vec2` that contains the first and second components of the given :obj:`~gi.repository.Graphene.Vec3`\. .. versionadded:: 1.0 .. method:: get_xy0() -> ~gi.repository.Graphene.Vec3 Creates a :obj:`~gi.repository.Graphene.Vec3` that contains the first two components of the given :obj:`~gi.repository.Graphene.Vec3`\, and the third component set to 0. .. versionadded:: 1.0 .. method:: get_xyz0() -> ~gi.repository.Graphene.Vec4 Converts a :obj:`~gi.repository.Graphene.Vec3` in a :obj:`~gi.repository.Graphene.Vec4` using 0.0 as the value for the fourth component of the resulting vector. .. versionadded:: 1.0 .. method:: get_xyz1() -> ~gi.repository.Graphene.Vec4 Converts a :obj:`~gi.repository.Graphene.Vec3` in a :obj:`~gi.repository.Graphene.Vec4` using 1.0 as the value for the fourth component of the resulting vector. .. versionadded:: 1.0 .. method:: get_xyzw(w: float) -> ~gi.repository.Graphene.Vec4 Converts a :obj:`~gi.repository.Graphene.Vec3` in a :obj:`~gi.repository.Graphene.Vec4` using ``w`` as the value of the fourth component of the resulting vector. .. versionadded:: 1.0 :param w: the value of the W component .. method:: get_y() -> float Retrieves the second component of the given vector ``v``\. .. versionadded:: 1.0 .. method:: get_z() -> float Retrieves the third component of the given vector ``v``\. .. versionadded:: 1.0 .. method:: init(x: float, y: float, z: float) -> ~gi.repository.Graphene.Vec3 Initializes a :obj:`~gi.repository.Graphene.Vec3` 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 .. method:: init_from_float(src: list[float]) -> ~gi.repository.Graphene.Vec3 Initializes a :obj:`~gi.repository.Graphene.Vec3` with the values from an array. .. versionadded:: 1.0 :param src: an array of 3 floating point values .. method:: init_from_vec3(src: ~gi.repository.Graphene.Vec3) -> ~gi.repository.Graphene.Vec3 Initializes a :obj:`~gi.repository.Graphene.Vec3` with the values of another :obj:`~gi.repository.Graphene.Vec3`\. .. versionadded:: 1.0 :param src: a :obj:`~gi.repository.Graphene.Vec3` .. method:: interpolate(v2: ~gi.repository.Graphene.Vec3, factor: float) -> ~gi.repository.Graphene.Vec3 Linearly interpolates ``v1`` and ``v2`` using the given ``factor``\. .. versionadded:: 1.10 :param v2: a :obj:`~gi.repository.Graphene.Vec3` :param factor: the interpolation factor .. method:: length() -> float Retrieves the length of the given vector ``v``\. .. versionadded:: 1.0 .. method:: max(b: ~gi.repository.Graphene.Vec3) -> ~gi.repository.Graphene.Vec3 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.Vec3` .. method:: min(b: ~gi.repository.Graphene.Vec3) -> ~gi.repository.Graphene.Vec3 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.Vec3` .. method:: multiply(b: ~gi.repository.Graphene.Vec3) -> ~gi.repository.Graphene.Vec3 Multiplies each component of the two given vectors. .. versionadded:: 1.0 :param b: a :obj:`~gi.repository.Graphene.Vec3` .. method:: near(v2: ~gi.repository.Graphene.Vec3, epsilon: float) -> bool Compares the two given :obj:`~gi.repository.Graphene.Vec3` vectors and checks whether their values are within the given ``epsilon``\. .. versionadded:: 1.2 :param v2: a :obj:`~gi.repository.Graphene.Vec3` :param epsilon: the threshold between the two vectors .. method:: negate() -> ~gi.repository.Graphene.Vec3 Negates the given :obj:`~gi.repository.Graphene.Vec3`\. .. versionadded:: 1.2 .. method:: normalize() -> ~gi.repository.Graphene.Vec3 Normalizes the given :obj:`~gi.repository.Graphene.Vec3`\. .. versionadded:: 1.0 .. classmethod:: one() -> ~gi.repository.Graphene.Vec3 Provides a constant pointer to a vector with three components, all sets to 1. .. versionadded:: 1.0 .. method:: scale(factor: float) -> ~gi.repository.Graphene.Vec3 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.Vec3) -> ~gi.repository.Graphene.Vec3 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.Vec3` .. method:: to_float() -> list[float] Copies the components of a :obj:`~gi.repository.Graphene.Vec3` into the given array. .. versionadded:: 1.0 .. classmethod:: x_axis() -> ~gi.repository.Graphene.Vec3 Provides a constant pointer to a vector with three components with values set to (1, 0, 0). .. versionadded:: 1.0 .. classmethod:: y_axis() -> ~gi.repository.Graphene.Vec3 Provides a constant pointer to a vector with three components with values set to (0, 1, 0). .. versionadded:: 1.0 .. classmethod:: z_axis() -> ~gi.repository.Graphene.Vec3 Provides a constant pointer to a vector with three components with values set to (0, 0, 1). .. versionadded:: 1.0 .. classmethod:: zero() -> ~gi.repository.Graphene.Vec3 Provides a constant pointer to a vector with three components, all sets to 0. .. versionadded:: 1.0 Fields ------ .. rst-class:: interim-class .. class:: Vec3 :no-index: .. attribute:: value