Point#

Added in version 1.0.

class Point(*args, **kwargs)#

A point with two coordinates.

Constructors#

class Point
classmethod alloc() Point#

Allocates a new Point structure.

The coordinates of the returned point are (0, 0).

It’s possible to chain this function with init() or init_from_point(), e.g.:

graphene_point_t *
point_new (float x, float y)
{
  return graphene_point_init (graphene_point_alloc (), x, y);
}

graphene_point_t *
point_copy (const graphene_point_t *p)
{
  return graphene_point_init_from_point (graphene_point_alloc (), p);
}

Added in version 1.0.

Methods#

class Point
distance(b: Point) Tuple[float, float, float]#

Computes the distance between a and b.

Added in version 1.0.

Parameters:

b – a Point

equal(b: Point) bool#

Checks if the two points a and b point to the same coordinates.

This function accounts for floating point fluctuations; if you want to control the fuzziness of the match, you can use near() instead.

Added in version 1.0.

Parameters:

b – a Point

free() None#

Frees the resources allocated by alloc().

Added in version 1.0.

init(x: float, y: float) Point#

Initializes p to the given x and y coordinates.

It’s safe to call this function multiple times.

Added in version 1.0.

Parameters:
  • x – the X coordinate

  • y – the Y coordinate

init_from_point(src: Point) Point#

Initializes p with the same coordinates of src.

Added in version 1.0.

Parameters:

src – the Point to use

init_from_vec2(src: Vec2) Point#

Initializes p with the coordinates inside the given Vec2.

Added in version 1.4.

Parameters:

src – a Vec2

interpolate(b: Point, factor: float) Point#

Linearly interpolates the coordinates of a and b using the given factor.

Added in version 1.0.

Parameters:
  • b – a Point

  • factor – the linear interpolation factor

near(b: Point, epsilon: float) bool#

Checks whether the two points a and b are within the threshold of epsilon.

Added in version 1.0.

Parameters:
  • b – a Point

  • epsilon – threshold between the two points

to_vec2() Vec2#

Stores the coordinates of the given Point into a Vec2.

Added in version 1.4.

classmethod zero() Point#

Returns a point fixed at (0, 0).

Added in version 1.0.

Fields#

class Point
x#

The X coordinate of the point

y#

The Y coordinate of the point