liba 0.1.15
An algorithm library based on C/C++
Loading...
Searching...
No Matches
three-dimensional point
Collaboration diagram for three-dimensional point:

Data Structures

struct  a_point3
 instance structure for three-dimensional point More...

Macros

#define A_POINT3_C(x, y, z)
#define a_point3_c(x)
#define a_point3_(_, x)

Typedefs

typedef struct a_point3 a_point3

Functions

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_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_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_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_set_cyl (a_point3 *ctx, a_real rho, a_real theta, a_real z)
 set the cylindrical 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_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_add (a_point3 const *lhs, a_vector3 const *rhs, a_point3 *res)
 add a 3D vector to a 3D point.
void a_point3_sub (a_point3 const *lhs, a_vector3 const *rhs, a_point3 *res)
 subtract a 3D vector from 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_div (a_point3 const *lhs, a_real rhs, a_point3 *res)
 divide a 3D point by a scalar.
void a_point3_pos (a_point3 const *ctx, a_vector3 *res)
 convert it into a vector from the origin to the point.
void a_point3_neg (a_point3 const *ctx, a_vector3 *res)
 convert it into a vector from the point to the origin.
a_real a_point3_dist (a_point3 const *lhs, a_point3 const *rhs)
 compute the distance between two 3D points.
a_real a_point3_dist2 (a_point3 const *lhs, a_point3 const *rhs)
 compute the squared distance between two 3D points.
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_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.
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.
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_point3 const &p, a_point3 const &q)
 set a 3D vector as the difference from point p to point q.

Detailed Description

Macro Definition Documentation

◆ a_point3_

#define a_point3_ ( _,
x )
Value:
a_cast_s(a_point3 _, x)
instance structure for three-dimensional point
Definition point3.h:193

◆ A_POINT3_C

#define A_POINT3_C ( x,
y,
z )
Value:
#define a_real_c(x)
static cast to floating-point number
Definition a.h:1009

constructs a three-dimensional point from cartesian coordinate

◆ a_point3_c

#define a_point3_c ( x)
Value:
a_cast_s(a_point3, x)

static cast to three-dimensional point

Function Documentation

◆ a_point3_cmpxy()

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.

Parameters
[in]lhsis left-hand side 3D point
[in]rhsis right-hand side 3D point
Returns
relationship between 3D points
Return values
>0if lhs is greater than rhs
<0if lhs is less than rhs
0if lhs is equal to rhs

◆ a_point3_cmpyx()

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.

Parameters
[in]lhsis left-hand side 3D point
[in]rhsis right-hand side 3D point
Returns
relationship between 3D points
Return values
>0if lhs is greater than rhs
<0if lhs is less than rhs
0if lhs is equal to rhs

◆ a_point3_dist()

a_real a_point3_dist ( a_point3 const * lhs,
a_point3 const * rhs )

compute the distance between two 3D points.

In three-dimensional space, let point \(p\) have coordinates \((p_x,p_y,p_z)\) and let point \(q\) have coordinates \((q_x,q_y,q_z)\). Then the distance between \(p\) and \(q\) is given by:

\[ d(p,q)=\sqrt{(p_x-q_x)^2+(p_y-q_y)^2+(p_z-q_z)^2} \]

Parameters
[in]lhsis left-hand side 3D point
[in]rhsis right-hand side 3D point
Returns
the distance between two 3D points

◆ a_point3_dist2()

a_real a_point3_dist2 ( a_point3 const * lhs,
a_point3 const * rhs )

compute the squared distance between two 3D points.

In three-dimensional space, let point \(p\) have coordinates \((p_x,p_y,p_z)\) and let point \(q\) have coordinates \((q_x,q_y,q_z)\). Then the squared distance between \(p\) and \(q\) is given by:

\[ d(p,q)^2=(p_x-q_x)^2+(p_y-q_y)^2+(p_z-q_z)^2 \]

Parameters
[in]lhsis left-hand side 3D point
[in]rhsis right-hand side 3D point
Returns
the squared distance between two 3D points

◆ a_point3_maxdist()

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.

Parameters
[in]ctxpoints to the reference point
[in]i_ppoints to the points in memory
[in]i_nnumber of the points in memory
[out]o_pstores the farthest point; may be NULL
[out]o_istores the index of the farthest point; may be NULL
Returns
the maximum distance from a reference point to a point set
Return values
-inffailure

◆ a_point3_mindist()

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.

Parameters
[in]ctxpoints to the reference point
[in]i_ppoints to the points in memory
[in]i_nnumber of the points in memory
[out]o_pstores the nearest point; may be NULL
[out]o_istores the index of the nearest point; may be NULL
Returns
the minimum distance from a reference point to a point set
Return values
+inffailure

◆ set()

void a_vector3::set ( a_point3 const & p,
a_point3 const & q )
inline

set a 3D vector as the difference from point p to point q.

See also
a_vector3_set