1.7 <GraphenePoint>

Structure: <GraphenePoint>

A point with two coordinates.

Fields

x

the X coordinate of the point

y

the Y coordinate of the point

Procedures

Procedure: point:alloc ⇒ %return

Allocates a new <GraphenePoint> structure.

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

It’s possible to chain this function with point:init or point: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);
  }
%return

Returned: a <GraphenePoint>.

the newly allocated <GraphenePoint>. Use point:free to free the resources allocated by this function.

Method: point:distance self b ⇒ %return d-x d-y
Method: distance self b ⇒ %return d-x d-y

Computes the distance between self and b.

self

Passed: a <GraphenePoint>.

a <GraphenePoint>

b

Passed: a <GraphenePoint>.

a <GraphenePoint>

%return

Returned: a real number.

the distance between the two points

d-x

Returned: a real number.

distance component on the X axis

d-y

Returned: a real number.

distance component on the Y axis

Method: point:equal? self b ⇒ %return
Method: equal? self b ⇒ %return

Checks if the two points self 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 point:near? instead.

self

Passed: a <GraphenePoint>.

a <GraphenePoint>

b

Passed: a <GraphenePoint>.

a <GraphenePoint>

%return

Returned: a boolean.

true if the points have the same coordinates

Method: point:free self
Method: free self

Frees the resources allocated by point:alloc.

self

Passed: a <GraphenePoint>.

a <GraphenePoint>

Method: point:init self x y ⇒ %return
Method: init self x y ⇒ %return

Initializes self to the given x and y coordinates.

It’s safe to call this function multiple times.

self

Passed: a <GraphenePoint>.

a <GraphenePoint>

x

Passed: a real number.

the X coordinate

y

Passed: a real number.

the Y coordinate

%return

Returned: a <GraphenePoint>.

the initialized point

Method: point:init-from-point self src ⇒ %return
Method: init-from-point self src ⇒ %return

Initializes self with the same coordinates of src.

self

Passed: a <GraphenePoint>.

a <GraphenePoint>

src

Passed: a <GraphenePoint>.

the <GraphenePoint> to use

%return

Returned: a <GraphenePoint>.

the initialized point

Method: point:init-from-vec2 self src ⇒ %return
Method: init-from-vec2 self src ⇒ %return

Initializes self with the coordinates inside the given <GrapheneVec2>.

self

Passed: a <GraphenePoint>.

the <GraphenePoint> to initialize

src

Passed: a <GrapheneVec2>.

a <GrapheneVec2>

%return

Returned: a <GraphenePoint>.

the initialized point

Method: point:interpolate! self b factor res ⇒ res
Method: interpolate! self b factor res ⇒ res

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

self

Passed: a <GraphenePoint>.

a <GraphenePoint>

b

Passed: a <GraphenePoint>.

a <GraphenePoint>

factor

Passed: a real number.

the linear interpolation factor

res

Passed, filled in, and returned: a <GraphenePoint>.

return location for the interpolated point

Method: point:near? self b epsilon ⇒ %return
Method: near? self b epsilon ⇒ %return

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

self

Passed: a <GraphenePoint>.

a <GraphenePoint>

b

Passed: a <GraphenePoint>.

a <GraphenePoint>

epsilon

Passed: a real number.

threshold between the two points

%return

Returned: a boolean.

true if the distance is within epsilon

Method: point:to-vec2! self v ⇒ v
Method: to-vec2! self v ⇒ v

Stores the coordinates of the given <GraphenePoint> into a <GrapheneVec2>.

self

Passed: a <GraphenePoint>.

a <GraphenePoint>

v

Passed, filled in, and returned: a <GrapheneVec2>.

return location for the vertex

Procedure: point:zero ⇒ %return

Returns a point fixed at (0, 0).

%return

Returned: a <GraphenePoint>.

a fixed point