Gimp.Vector2¶
Fields¶
Name |
Type |
Access |
Description |
---|---|---|---|
x |
r/w |
the x axis |
|
y |
r/w |
the y axis |
Methods¶
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- class Gimp.Vector2¶
A two dimensional vector.
- classmethod add(vector1, vector2)¶
- Parameters:
vector1 (
Gimp.Vector2
) – a pointer to the firstGimp.Vector2
.vector2 (
Gimp.Vector2
) – a pointer to the secondGimp.Vector2
.
- Returns:
destination for the resulting
Gimp.Vector2
.- Return type:
result:
Gimp.Vector2
Computes the sum of two 2D vectors. The resulting
Gimp.Vector2
is stored in result.
- classmethod new(x, y)¶
- Parameters:
- Returns:
the resulting vector
- Return type:
Creates a [struct`Vector2`] of coordinates x and y.
- classmethod sub(vector1, vector2)¶
- Parameters:
vector1 (
Gimp.Vector2
) – a pointer to the firstGimp.Vector2
.vector2 (
Gimp.Vector2
) – a pointer to the secondGimp.Vector2
.
- Returns:
the destination for the resulting
Gimp.Vector2
.- Return type:
result:
Gimp.Vector2
Computes the difference of two 2D vectors (vector1 minus vector2). The resulting
Gimp.Vector2
is stored in result.
- add_val(vector2)¶
- Parameters:
vector2 (
Gimp.Vector2
) – the secondGimp.Vector2
.- Returns:
the resulting
Gimp.Vector2
.- Return type:
This function is identical to
Gimp.Vector2.add
() but the vectors are passed by value rather than by reference.
- cross_product(vector2)¶
- Parameters:
vector2 (
Gimp.Vector2
) – a pointer to the secondGimp.Vector2
.- Returns:
The cross product.
- Return type:
Compute the cross product of two vectors. The result is a
Gimp.Vector2
which is orthogonal to both self and vector2. If self and vector2 are parallel, the result will be the nul vector.Note that in 2D, this function is useful to test if two vectors are parallel or not, or to compute the area spawned by two vectors.
- cross_product_val(vector2)¶
- Parameters:
vector2 (
Gimp.Vector2
) – the secondGimp.Vector2
.- Returns:
The cross product.
- Return type:
Identical to [method`Vector2`.cross_product], but the vectors are passed by value rather than by reference.
- inner_product(vector2)¶
- Parameters:
vector2 (
Gimp.Vector2
) – a pointer to the secondGimp.Vector2
.- Returns:
The inner product.
- Return type:
Computes the inner (dot) product of two 2D vectors. This product is zero if and only if the two vectors are orthogonal.
- inner_product_val(vector2)¶
- Parameters:
vector2 (
Gimp.Vector2
) – the secondGimp.Vector2
.- Returns:
The inner product.
- Return type:
Identical to [method`Vector2`.inner_product], but the vectors are passed by value rather than by reference.
- length()¶
-
Computes the length of a 2D vector.
- length_val()¶
-
Identical to [method`Vector2`.length], but the vector is passed by value rather than by reference.
- mul(factor)¶
- Parameters:
factor (
float
) – a scalar.
Multiplies each component of the self by factor. Note that this is equivalent to multiplying the vectors length by factor.
- mul_val(factor)¶
- Parameters:
factor (
float
) – a scalar.- Returns:
the resulting
Gimp.Vector2
.- Return type:
Identical to [method`Vector2`.mul], but the vector is passed by value rather than by reference.
- neg()¶
Negates the self (i.e. negate all its coordinates).
- neg_val()¶
- Returns:
the negated
Gimp.Vector2
.- Return type:
Identical to [method`Vector2`.neg], but the vector is passed by value rather than by reference.
- normal()¶
- Returns:
a
Gimp.Vector2
perpendicular to self, with a length of 1.0.- Return type:
Compute a normalized perpendicular vector to self
New in version 2.8.
- normal_val()¶
- Returns:
a
Gimp.Vector2
perpendicular to self, with a length of 1.0.- Return type:
Identical to [method`Vector2`.normal], but the vector is passed by value rather than by reference.
New in version 2.8.
- normalize()¶
Normalizes the self so the length of the self is 1.0. The nul vector will not be changed.
- normalize_val()¶
- Returns:
a
Gimp.Vector2
parallel to self, pointing in the same direction but with a length of 1.0.- Return type:
Identical to [method`Vector2`.normalize], but the vector is passed by value rather than by reference.
- rotate(alpha)¶
- Parameters:
alpha (
float
) – an angle (in radians).
Rotates the self counterclockwise by alpha radians.
- rotate_val(alpha)¶
- Parameters:
alpha (
float
) – an angle (in radians).- Returns:
a
Gimp.Vector2
representing self rotated by alpha radians.- Return type:
Identical to [method`Vector2`.rotate], but the vector is passed by value rather than by reference.
- set(x, y)¶
-
Sets the X and Y coordinates of self to x and y.
- sub_val(vector2)¶
- Parameters:
vector2 (
Gimp.Vector2
) – the secondGimp.Vector2
.- Returns:
the resulting
Gimp.Vector2
.- Return type:
This function is identical to
Gimp.Vector2.sub
() but the vectors are passed by value rather than by reference.