| Top |
| #define | GRAPHENE_POINT_INIT() |
| graphene_point_t * | graphene_point_alloc () |
| void | graphene_point_free () |
| graphene_point_t * | graphene_point_init () |
| graphene_point_t * | graphene_point_init_from_point () |
| graphene_point_t * | graphene_point_init_from_vec2 () |
| bool | graphene_point_equal () |
| float | graphene_point_distance () |
| bool | graphene_point_near () |
| void | graphene_point_interpolate () |
| void | graphene_point_to_vec2 () |
| const graphene_point_t * | graphene_point_zero () |
graphene_point_t is a data structure capable of describing a point with two coordinates:
graphene_point_t.x
graphene_point_t.y
#define GRAPHENE_POINT_INIT(x,y) { x, y }
Initializes a graphene_point_t with the given coordinates when declaring it, e.g:
1 |
graphene_point_t p = GRAPHENE_POINT_INIT (10.f, 10.f); |
Since: 1.0
graphene_point_t *
graphene_point_alloc (void);
Allocates a new graphene_point_t structure.
The coordinates of the returned point are (0, 0).
It's possible to chain this function with graphene_point_init()
or graphene_point_init_from_point(), e.g.:
1 2 3 4 5 6 7 8 9 10 11 |
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); } |
[constructor]
the newly allocated graphene_point_t.
Use graphene_point_free() to free the resources allocated by
this function.
[transfer full]
Since: 1.0
void
graphene_point_free (graphene_point_t *p);
Frees the resources allocated by graphene_point_alloc().
Since: 1.0
graphene_point_t * graphene_point_init (graphene_point_t *p,float x,float y);
Initializes p
to the given x
and y
coordinates.
It's safe to call this function multiple times.
Since: 1.0
graphene_point_t * graphene_point_init_from_point (graphene_point_t *p,const graphene_point_t *src);
Initializes p
with the same coordinates of src
.
Since: 1.0
graphene_point_t * graphene_point_init_from_vec2 (graphene_point_t *p,const graphene_vec2_t *src);
Initializes p
with the coordinates inside the given graphene_vec2_t.
Since: 1.4
bool graphene_point_equal (const graphene_point_t *a,const graphene_point_t *b);
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
graphene_point_near() instead.
Since: 1.0
float graphene_point_distance (const graphene_point_t *a,const graphene_point_t *b,float *d_x,float *d_y);
Computes the distance between a
and b
.
a |
||
b |
||
d_x |
distance component on the X axis. |
[out][optional] |
d_y |
distance component on the Y axis. |
[out][optional] |
Since: 1.0
bool graphene_point_near (const graphene_point_t *a,const graphene_point_t *b,float epsilon);
Checks whether the two points a
and b
are within
the threshold of epsilon
.
Since: 1.0
void graphene_point_interpolate (const graphene_point_t *a,const graphene_point_t *b,double factor,graphene_point_t *res);
Linearly interpolates the coordinates of a
and b
using the
given factor
.
a |
||
b |
||
factor |
the linear interpolation factor |
|
res |
return location for the interpolated point. |
[out caller-allocates] |
Since: 1.0
void graphene_point_to_vec2 (const graphene_point_t *p,graphene_vec2_t *v);
Stores the coordinates of the given graphene_point_t into a graphene_vec2_t.
Since: 1.4
const graphene_point_t *
graphene_point_zero (void);
Returns a point fixed at (0, 0).
Since: 1.0
#define GRAPHENE_POINT_INIT_ZERO GRAPHENE_POINT_INIT (0.f, 0.f)
Initializes a graphene_point_t to (0, 0) when declaring it.
Since: 1.0
typedef struct {
float x;
float y;
} graphene_point_t;
A point with two coordinates.
Since: 1.0