Gimp.Vector3

Fields

Name

Type

Access

Description

x

float

r/w

the x axis

y

float

r/w

the y axis

z

float

r/w

the z axis

Methods

class

add (vector1, vector2)

class

new (x, y, z)

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 ()

normalize ()

normalize_val ()

rotate (alpha, beta, gamma)

rotate_val (alpha, beta, gamma)

set (x, y, z)

sub_val (vector2)

Details

class Gimp.Vector3

A three dimensional vector.

classmethod add(vector1, vector2)
Parameters:
Returns:

destination for the resulting Gimp.Vector3.

Return type:

result: Gimp.Vector3

Computes the sum of two 3D vectors. The resulting Gimp.Vector3 is stored in result.

classmethod new(x, y, z)
Parameters:
  • x (float) – the X coordinate.

  • y (float) – the Y coordinate.

  • z (float) – the Z coordinate.

Returns:

the resulting Gimp.Vector3.

Return type:

Gimp.Vector3

Creates a Gimp.Vector3 of coordinate x, y and z.

classmethod sub(vector1, vector2)
Parameters:
Returns:

the destination for the resulting Gimp.Vector3.

Return type:

result: Gimp.Vector3

Computes the difference of two 3D vectors (vector1 minus vector2). The resulting Gimp.Vector3 is stored in result.

add_val(vector2)
Parameters:

vector2 (Gimp.Vector3) – a Gimp.Vector3.

Returns:

the resulting Gimp.Vector3.

Return type:

Gimp.Vector3

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

cross_product(vector2)
Parameters:

vector2 (Gimp.Vector3) – a pointer to the second Gimp.Vector3.

Returns:

The cross product.

Return type:

Gimp.Vector3

Compute the cross product of two vectors. The result is a Gimp.Vector3 which is orthogonal to both self and vector2. If self and vector2 and parallel, the result will be the nul vector.

This function can be used to compute the normal of the plane defined by self and vector2.

cross_product_val(vector2)
Parameters:

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

Returns:

The cross product.

Return type:

Gimp.Vector3

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

inner_product(vector2)
Parameters:

vector2 (Gimp.Vector3) – a pointer to the second Gimp.Vector3.

Returns:

The inner product.

Return type:

float

Computes the inner (dot) product of two 3D vectors. This product is zero if and only if the two vectors are orthogonal.

inner_product_val(vector2)
Parameters:

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

Returns:

The inner product.

Return type:

float

Identical to [method`Vector3`.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 3D vector.

length_val()
Returns:

the length of self (a positive float).

Return type:

float

Identical to [method`Vector3`.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.Vector3.

Return type:

Gimp.Vector3

Identical to [method`Vector3`.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.Vector3.

Return type:

Gimp.Vector3

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

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.Vector3 parallel to self, pointing in the same direction but with a length of 1.0.

Return type:

Gimp.Vector3

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

rotate(alpha, beta, gamma)
Parameters:
  • alpha (float) – the angle (in radian) of rotation around the Z axis.

  • beta (float) – the angle (in radian) of rotation around the Y axis.

  • gamma (float) – the angle (in radian) of rotation around the X axis.

Rotates the self around the three axis (Z, Y, and X) by alpha, beta and gamma, respectively.

Note that the order of the rotation is very important. If you expect a vector to be rotated around X, and then around Y, you will have to call this function twice. Also, it is often wise to call this function with only one of alpha, beta and gamma non-zero.

rotate_val(alpha, beta, gamma)
Parameters:
  • alpha (float) – the angle (in radian) of rotation around the Z axis.

  • beta (float) – the angle (in radian) of rotation around the Y axis.

  • gamma (float) – the angle (in radian) of rotation around the X axis.

Returns:

the rotated vector.

Return type:

Gimp.Vector3

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

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

  • y (float) – the Y coordinate.

  • z (float) – the Z coordinate.

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

sub_val(vector2)
Parameters:

vector2 (Gimp.Vector3) – a Gimp.Vector3.

Returns:

the resulting Gimp.Vector3.

Return type:

Gimp.Vector3

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