20#define A_POINT3_C(x, y, z) {a_real_c(x), a_real_c(y), a_real_c(z)}
24#define a_point3_c(x) a_cast_s(a_point3, x)
25#define a_point3_(_, x) a_cast_s(a_point3 _, x)
29#if defined(__cplusplus)
36#if !defined A_HAVE_INLINE || defined(LIBA_POINT3_C)
39#define A_INTERN A_PUBLIC extern
175#if !defined A_HAVE_INLINE || defined(LIBA_POINT3_C)
178#define A_INTERN static A_INLINE
181#if defined(__cplusplus)
195#if defined(__cplusplus)
337#if defined(LIBA_POINT3_C)
340#define A_INTERN A_INLINE
343#if defined(A_HAVE_INLINE) || defined(LIBA_POINT3_C)
347 ctx->x = q->x - p->x;
348 ctx->y = q->y - p->y;
349 ctx->z = q->z - p->z;
365 a_real_cart2pol(ctx->x, ctx->y, rho, theta);
370 a_real_pol2cart(rho, theta, &ctx->x, &ctx->y);
375 a_real_cart2sph(ctx->x, ctx->y, ctx->z, rho, theta, alpha);
379 a_real_sph2cart(rho, theta, alpha, &ctx->x, &ctx->y, &ctx->z);
383 res->x = lhs->x + rhs->x;
384 res->y = lhs->y + rhs->y;
385 res->z = lhs->z + rhs->z;
389 res->x = lhs->x - rhs->x;
390 res->y = lhs->y - rhs->y;
391 res->z = lhs->z - rhs->z;
395 res->x = lhs->x * rhs;
396 res->y = lhs->y * rhs;
397 res->z = lhs->z * rhs;
401 res->x = lhs->x / rhs;
402 res->y = lhs->y / rhs;
403 res->z = lhs->z / rhs;
419#if defined(LIBA_POINT3_C)
422#define A_INTERN static A_INLINE
void a_point3_val(a_point3 const *ctx, a_real *x, a_real *y, a_real *z)
get the cartesian coordinates of a 3D point.
void a_point3_pos(a_point3 const *ctx, a_vector3 *res)
convert it into a vector from the origin to the point.
a_real a_point3_dist(a_point3 const *lhs, a_point3 const *rhs)
compute the distance between two 3D points.
void set(a_point3 const &p, a_point3 const &q)
set a 3D vector as the difference from point p to point q.
Definition point3.h:183
void a_point3_set_cyl(a_point3 *ctx, a_real rho, a_real theta, a_real z)
set the cylindrical coordinates of a 3D point.
int a_point3_cmpyx(a_point3 const *lhs, a_point3 const *rhs)
compare two 3D points primarily by Y, then by X, and finally by Z.
void a_vector3_set(a_vector3 *ctx, a_point3 const *p, a_point3 const *q)
set a 3D vector as the difference from point p to point q.
void a_point3_add(a_point3 const *lhs, a_vector3 const *rhs, a_point3 *res)
add a 3D vector to a 3D point.
a_real a_point3_mindist(a_point3 const *ctx, a_point3 const *i_p, a_size i_n, a_point3 *o_p, a_size *o_i)
compute the minimum distance from a reference point to a point set.
a_real a_point3_dist2(a_point3 const *lhs, a_point3 const *rhs)
compute the squared distance between two 3D points.
int a_point3_cmpxy(a_point3 const *lhs, a_point3 const *rhs)
compare two 3D points primarily by X, then by Y, and finally by Z.
a_real a_point3_maxdist(a_point3 const *ctx, a_point3 const *i_p, a_size i_n, a_point3 *o_p, a_size *o_i)
compute the maximum distance from a reference point to a point set.
void a_point3_set_sph(a_point3 *ctx, a_real rho, a_real theta, a_real alpha)
set the spherical coordinates of a 3D point.
void a_point3_set_val(a_point3 *ctx, a_real x, a_real y, a_real z)
set the cartesian coordinates of a 3D point.
void a_point3_sph(a_point3 const *ctx, a_real *rho, a_real *theta, a_real *alpha)
get the spherical coordinates of a 3D point.
void a_point3_mul(a_point3 const *lhs, a_real rhs, a_point3 *res)
multiplie a 3D point by a scalar.
void a_point3_cyl(a_point3 const *ctx, a_real *rho, a_real *theta, a_real *z)
get the cylindrical coordinates of a 3D point.
void a_point3_div(a_point3 const *lhs, a_real rhs, a_point3 *res)
divide a 3D point by a scalar.
void a_point3_neg(a_point3 const *ctx, a_vector3 *res)
convert it into a vector from the point to the origin.
void a_point3_sub(a_point3 const *lhs, a_vector3 const *rhs, a_point3 *res)
subtract a 3D vector from a 3D 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 three-dimensional point
Definition point3.h:193
a_real mindist(a_point3 const *i_p, a_size i_n, a_point3 *o_p=NULL, a_size *o_i=NULL) const
compute the minimum distance from a reference point to a point set.
Definition point3.h:261
a_real maxdist(a_point3 const *i_p, a_size i_n, a_point3 *o_p=NULL, a_size *o_i=NULL) const
compute the maximum distance from a reference point to a point set.
Definition point3.h:266
friend void operator/=(a_point3 &lhs, a_real rhs)
divide a 3D point by a scalar.
Definition point3.h:312
a_real dist2(a_point3 const &rhs) const
compute the squared distance between two 3D points.
Definition point3.h:259
friend a_point3 operator*(a_point3 const &lhs, a_real rhs)
multiplie a 3D point by a scalar.
Definition point3.h:305
friend a_point3 operator/(a_point3 const &lhs, a_real rhs)
divide a 3D point by a scalar.
Definition point3.h:314
friend void operator+=(a_point3 &lhs, a_vector3 const &rhs)
add a 3D vector to a 3D point.
Definition point3.h:271
void sph(a_real &rho, a_real &theta, a_real &alpha) const
get the spherical coordinates of a 3D point.
Definition point3.h:217
friend a_vector3 operator+(a_point3 const &rhs)
convert it into a vector from the origin to the point.
Definition point3.h:321
friend a_point3 operator-(a_point3 const &lhs, a_vector3 const &rhs)
subtract a 3D vector from a 3D point.
Definition point3.h:282
void cyl(a_real &rho, a_real &theta, a_real &z_) const
get the cylindrical coordinates of a 3D point.
Definition point3.h:207
void neg(a_vector3 &res) const
convert it into a vector from the point to the origin.
Definition point3.h:252
void val(a_real &x_, a_real &y_, a_real &z_) const
get the cartesian coordinates of a 3D point.
Definition point3.h:197
void sub(a_vector3 const &rhs, a_point3 &res) const
subtract a 3D vector from a 3D point.
Definition point3.h:232
friend void operator*=(a_point3 &lhs, a_real rhs)
multiplie a 3D point by a scalar.
Definition point3.h:296
void set_val(a_real x_, a_real y_, a_real z_)
set the cartesian coordinates of a 3D point.
Definition point3.h:202
void add(a_vector3 const &rhs, a_point3 &res) const
add a 3D vector to a 3D point.
Definition point3.h:227
void set_sph(a_real rho, a_real theta, a_real alpha)
set the spherical coordinates of a 3D point.
Definition point3.h:222
void pos(a_vector3 &res) const
convert it into a vector from the origin to the point.
Definition point3.h:247
void div(a_real rhs, a_point3 &res) const
divide a 3D point by a scalar.
Definition point3.h:242
void mul(a_real rhs, a_point3 &res) const
multiplie a 3D point by a scalar.
Definition point3.h:237
friend a_point3 operator+(a_point3 const &lhs, a_vector3 const &rhs)
add a 3D vector to a 3D point.
Definition point3.h:273
void set_cyl(a_real rho, a_real theta, a_real z_)
set the cylindrical coordinates of a 3D point.
Definition point3.h:212
a_real dist(a_point3 const &rhs) const
compute the distance between two 3D points.
Definition point3.h:257
friend a_point3 operator*(a_real lhs, a_point3 const &rhs)
multiplie a 3D point by a scalar.
Definition point3.h:298
friend void operator-=(a_point3 &lhs, a_vector3 const &rhs)
subtract a 3D vector from a 3D point.
Definition point3.h:280
friend a_vector3 operator-(a_point3 const &rhs)
convert it into a vector from the point to the origin.
Definition point3.h:328
friend a_vector3 operator-(a_point3 const &lhs, a_point3 const &rhs)
set a 3D vector as the difference from point p to point q.
Definition point3.h:289
instance structure for three-dimensional vector
Definition vector3.h:387