Gimp.Vector2

Fields

Name

Type

Access

Description

x

float

r/w

the x axis

y

float

r/w

the y axis

Methods

class

add (vector1, vector2)

class

new (x, y)

class

sub (vector1, vector2)

add_val (vector2)

cross_product (vector2)

cross_product_val (vector2)

inner_product (vector2)

inner_product_val (vector2)

length ()

length_val ()

mul (factor)

mul_val (factor)

neg ()

neg_val ()

normal ()

normal_val ()

normalize ()

normalize_val ()

rotate (alpha)

rotate_val (alpha)

set (x, y)

sub_val (vector2)

Details

class Gimp.Vector2

A two dimensional vector.

classmethod add(vector1, vector2)
Parameters:
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:
  • x (float) – the X coordinate.

  • y (float) – the Y coordinate.

Returns:

the resulting vector

Return type:

Gimp.Vector2

Creates a [struct`Vector2`] of coordinates x and y.

classmethod sub(vector1, vector2)
Parameters:
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 second Gimp.Vector2.

Returns:

the resulting Gimp.Vector2.

Return type:

Gimp.Vector2

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 second Gimp.Vector2.

Returns:

The cross product.

Return type:

Gimp.Vector2

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 second Gimp.Vector2.

Returns:

The cross product.

Return type:

Gimp.Vector2

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 second Gimp.Vector2.

Returns:

The inner product.

Return type:

float

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 second Gimp.Vector2.

Returns:

The inner product.

Return type:

float

Identical to [method`Vector2`.inner_product], but the vectors are passed by value rather than by reference.

length()
Returns:

the length of self (a positive float).

Return type:

float

Computes the length of a 2D vector.

length_val()
Returns:

the length of self (a positive float).

Return type:

float

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:

Gimp.Vector2

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:

Gimp.Vector2

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:

Gimp.Vector2

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:

Gimp.Vector2

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:

Gimp.Vector2

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:

Gimp.Vector2

Identical to [method`Vector2`.rotate], but the vector is passed by value rather than by reference.

set(x, y)
Parameters:
  • x (float) – the X coordinate.

  • y (float) – the Y coordinate.

Sets the X and Y coordinates of self to x and y.

sub_val(vector2)
Parameters:

vector2 (Gimp.Vector2) – the second Gimp.Vector2.

Returns:

the resulting Gimp.Vector2.

Return type:

Gimp.Vector2

This function is identical to Gimp.Vector2.sub() but the vectors are passed by value rather than by reference.