20#define A_POINT2_C(x, y) {a_real_c(x), a_real_c(y)}
24#define a_point2_c(x) a_cast_s(a_point2, x)
25#define a_point2_(_, x) a_cast_s(a_point2 _, x)
29#if defined(__cplusplus)
36#if !defined A_HAVE_INLINE || defined(LIBA_POINT2_C)
39#define A_INTERN A_PUBLIC extern
167#if !defined A_HAVE_INLINE || defined(LIBA_POINT2_C)
170#define A_INTERN static A_INLINE
173#if defined(__cplusplus)
187#if defined(__cplusplus)
319#if defined(LIBA_POINT2_C)
322#define A_INTERN A_INLINE
325#if defined(A_HAVE_INLINE) || defined(LIBA_POINT2_C)
329 ctx->x = q->x - p->x;
330 ctx->y = q->y - p->y;
344 a_real_cart2pol(ctx->x, ctx->y, rho, theta);
348 a_real_pol2cart(rho, theta, &ctx->x, &ctx->y);
352 res->x = lhs->x + rhs->x;
353 res->y = lhs->y + rhs->y;
357 res->x = lhs->x - rhs->x;
358 res->y = lhs->y - rhs->y;
362 res->x = lhs->x * rhs;
363 res->y = lhs->y * rhs;
367 res->x = lhs->x / rhs;
368 res->y = lhs->y / rhs;
382#if defined(LIBA_POINT2_C)
385#define A_INTERN static A_INLINE
void set(a_point2 const &p, a_point2 const &q)
set a 2D vector as the difference from point p to point q.
Definition point2.h:175
a_real a_point2_dist(a_point2 const *lhs, a_point2 const *rhs)
compute the distance between two 2D points.
void a_vector2_set(a_vector2 *ctx, a_point2 const *p, a_point2 const *q)
set a 2D vector as the difference from point p to point q.
void a_point2_pol(a_point2 const *ctx, a_real *rho, a_real *theta)
get the polar coordinates of a 2D point.
void a_point2_div(a_point2 const *lhs, a_real rhs, a_point2 *res)
divide a 2D point by a scalar.
a_real a_point2_dist2(a_point2 const *lhs, a_point2 const *rhs)
compute the squared distance between two 2D points.
void a_point2_neg(a_point2 const *ctx, a_vector2 *res)
convert it into a vector from the point to the origin.
a_real a_point2_maxdist(a_point2 const *ctx, a_point2 const *i_p, a_size i_n, a_point2 *o_p, a_size *o_i)
compute the maximum distance from a reference point to a point set.
void a_point2_pos(a_point2 const *ctx, a_vector2 *res)
convert it into a vector from the origin to the point.
int a_point2_cmpy(a_point2 const *lhs, a_point2 const *rhs)
compare two 2D points primarily by Y-coordinate, then by X-coordinate.
void a_point2_set_pol(a_point2 *ctx, a_real rho, a_real theta)
set the polar coordinates of a 2D point.
void a_point2_val(a_point2 const *ctx, a_real *x, a_real *y)
get the cartesian coordinates of a 2D point.
a_real a_point2_mindist(a_point2 const *ctx, a_point2 const *i_p, a_size i_n, a_point2 *o_p, a_size *o_i)
compute the minimum distance from a reference point to a point set.
void a_point2_set_val(a_point2 *ctx, a_real x, a_real y)
set the cartesian coordinates of a 2D point.
void a_point2_add(a_point2 const *lhs, a_vector2 const *rhs, a_point2 *res)
add a 2D vector to a 2D point.
void a_point2_mul(a_point2 const *lhs, a_real rhs, a_point2 *res)
multiplie a 2D point by a scalar.
int a_point2_cmpx(a_point2 const *lhs, a_point2 const *rhs)
compare two 2D points primarily by X-coordinate, then by Y-coordinate.
void a_point2_sub(a_point2 const *lhs, a_vector2 const *rhs, a_point2 *res)
subtract a 2D vector from a 2D point.
double a_real
compiler built-in floating-point number type
Definition a.h:1012
size_t a_size
unsigned integer type returned by the sizeof operator
Definition a.h:823
instance structure for two-dimensional point
Definition point2.h:185
void mul(a_real rhs, a_point2 &res) const
multiplie a 2D point by a scalar.
Definition point2.h:219
friend void operator/=(a_point2 &lhs, a_real rhs)
divide a 2D point by a scalar.
Definition point2.h:294
friend void operator*=(a_point2 &lhs, a_real rhs)
multiplie a 2D point by a scalar.
Definition point2.h:278
void add(a_vector2 const &rhs, a_point2 &res) const
add a 2D vector to a 2D point.
Definition point2.h:209
friend void operator-=(a_point2 &lhs, a_vector2 const &rhs)
subtract a 2D vector from a 2D point.
Definition point2.h:262
friend a_vector2 operator-(a_point2 const &lhs, a_point2 const &rhs)
set a 2D vector as the difference from point p to point q.
Definition point2.h:271
void set_pol(a_real rho, a_real theta)
set the polar coordinates of a 2D point.
Definition point2.h:204
friend a_point2 operator+(a_point2 const &lhs, a_vector2 const &rhs)
add a 2D vector to a 2D point.
Definition point2.h:255
friend void operator+=(a_point2 &lhs, a_vector2 const &rhs)
add a 2D vector to a 2D point.
Definition point2.h:253
void div(a_real rhs, a_point2 &res) const
divide a 2D point by a scalar.
Definition point2.h:224
friend a_point2 operator-(a_point2 const &lhs, a_vector2 const &rhs)
subtract a 2D vector from a 2D point.
Definition point2.h:264
void pos(a_vector2 &res) const
convert it into a vector from the origin to the point.
Definition point2.h:229
a_real dist(a_point2 const &rhs) const
compute the distance between two 2D points.
Definition point2.h:239
a_real maxdist(a_point2 const *i_p, a_size i_n, a_point2 *o_p=NULL, a_size *o_i=NULL) const
compute the maximum distance from a reference point to a point set.
Definition point2.h:248
void sub(a_vector2 const &rhs, a_point2 &res) const
subtract a 2D vector from a 2D point.
Definition point2.h:214
friend a_vector2 operator+(a_point2 const &rhs)
convert it into a vector from the origin to the point.
Definition point2.h:303
void neg(a_vector2 &res) const
convert it into a vector from the point to the origin.
Definition point2.h:234
friend a_vector2 operator-(a_point2 const &rhs)
convert it into a vector from the point to the origin.
Definition point2.h:310
void set_val(a_real x_, a_real y_)
set the cartesian coordinates of a 2D point.
Definition point2.h:194
friend a_point2 operator/(a_point2 const &lhs, a_real rhs)
divide a 2D point by a scalar.
Definition point2.h:296
void pol(a_real &rho, a_real &theta) const
get the polar coordinates of a 2D point.
Definition point2.h:199
void val(a_real &x_, a_real &y_) const
get the cartesian coordinates of a 2D point.
Definition point2.h:189
friend a_point2 operator*(a_real lhs, a_point2 const &rhs)
multiplie a 2D point by a scalar.
Definition point2.h:280
a_real dist2(a_point2 const &rhs) const
compute the squared distance between two 2D points.
Definition point2.h:241
a_real mindist(a_point2 const *i_p, a_size i_n, a_point2 *o_p=NULL, a_size *o_i=NULL) const
compute the minimum distance from a reference point to a point set.
Definition point2.h:243
friend a_point2 operator*(a_point2 const &lhs, a_real rhs)
multiplie a 2D point by a scalar.
Definition point2.h:287
instance structure for two-dimensional vector
Definition vector2.h:315