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

Data Structures

struct  a_point2
 instance structure for two-dimensional point More...

Macros

#define A_POINT2_C(x, y)
#define a_point2_c(x)
#define a_point2_(_, x)

Typedefs

typedef struct a_point2 a_point2

Functions

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_val (a_point2 const *ctx, a_real *x, a_real *y)
 get the cartesian coordinates of a 2D point.
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_pol (a_point2 const *ctx, a_real *rho, a_real *theta)
 get the polar coordinates of a 2D point.
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_add (a_point2 const *lhs, a_vector2 const *rhs, a_point2 *res)
 add a 2D vector to a 2D point.
void a_point2_sub (a_point2 const *lhs, a_vector2 const *rhs, a_point2 *res)
 subtract a 2D vector from a 2D point.
void a_point2_mul (a_point2 const *lhs, a_real rhs, a_point2 *res)
 multiplie a 2D point by a scalar.
void a_point2_div (a_point2 const *lhs, a_real rhs, a_point2 *res)
 divide a 2D point by a scalar.
void a_point2_pos (a_point2 const *ctx, a_vector2 *res)
 convert it into a vector from the origin to the point.
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_dist (a_point2 const *lhs, a_point2 const *rhs)
 compute the distance between two 2D points.
a_real a_point2_dist2 (a_point2 const *lhs, a_point2 const *rhs)
 compute the squared distance between two 2D points.
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.
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.
int a_point2_cmpx (a_point2 const *lhs, a_point2 const *rhs)
 compare two 2D points primarily by X-coordinate, then by Y-coordinate.
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_vector2::set (a_point2 const &p, a_point2 const &q)
 set a 2D vector as the difference from point p to point q.

Detailed Description

Macro Definition Documentation

◆ a_point2_

#define a_point2_ ( _,
x )
Value:
a_cast_s(a_point2 _, x)
instance structure for two-dimensional point
Definition point2.h:185

◆ A_POINT2_C

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

constructs a two-dimensional point from cartesian coordinate

◆ a_point2_c

#define a_point2_c ( x)
Value:
a_cast_s(a_point2, x)

static cast to two-dimensional point

Function Documentation

◆ a_point2_cmpx()

int a_point2_cmpx ( a_point2 const * lhs,
a_point2 const * rhs )

compare two 2D points primarily by X-coordinate, then by Y-coordinate.

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

◆ a_point2_cmpy()

int a_point2_cmpy ( a_point2 const * lhs,
a_point2 const * rhs )

compare two 2D points primarily by Y-coordinate, then by X-coordinate.

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

◆ a_point2_dist()

a_real a_point2_dist ( a_point2 const * lhs,
a_point2 const * rhs )

compute the distance between two 2D points.

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

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

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

◆ a_point2_dist2()

a_real a_point2_dist2 ( a_point2 const * lhs,
a_point2 const * rhs )

compute the squared distance between two 2D points.

In two-dimensional space, let point \(p\) have coordinates \((p_x,p_y)\) and let point \(q\) have coordinates \((q_x,q_y)\). 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 \]

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

◆ a_point2_maxdist()

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.

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_point2_mindist()

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.

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_vector2::set ( a_point2 const & p,
a_point2 const & q )
inline

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

See also
a_vector2_set