19#define a_line2_c(x) a_cast_s(a_line2, x)
20#define a_line2_(_, x) a_cast_s(a_line2 _, x)
24#if defined(__cplusplus)
31#if !defined A_HAVE_INLINE || defined(LIBA_LINE2_C)
34#define A_INTERN A_PUBLIC extern
280#if !defined A_HAVE_INLINE || defined(LIBA_LINE2_C)
283#define A_INTERN static A_INLINE
286#if defined(__cplusplus)
298#if defined(__cplusplus)
379 return a_line2_segdist(
this, min1, max1, &rhs, min2, max2, &w1, &p1, &w2, &p2);
385 return a_line2_segdist2(
this, min1, max1, &rhs, min2, max2, &w1, &p1, &w2, &p2);
396 return a_line2_int1(
this, min1, max1, &rhs, min2, max2, &w1, &w2);
411#if defined(LIBA_LINE2_C)
414#define A_INTERN A_INLINE
417#if defined(A_HAVE_INLINE) || defined(LIBA_LINE2_C)
449 res->x = o->x + d->x * w;
450 res->y = o->y + d->y * w;
454#if defined(LIBA_LINE2_C)
457#define A_INTERN static A_INLINE
a_real a_line2_segdist(a_line2 const *ctx, a_real min1, a_real max1, a_line2 const *rhs, a_real min2, a_real max2, a_real *w1, a_point2 *p1, a_real *w2, a_point2 *p2)
compute the distance between two line segments.
void a_line2_eval(a_line2 const *ctx, a_real w, a_point2 *res)
evaluate a point on the line at a given parameter.
a_real a_line2_segdist2(a_line2 const *ctx, a_real min1, a_real max1, a_line2 const *rhs, a_real min2, a_real max2, a_real *w1, a_point2 *p1, a_real *w2, a_point2 *p2)
compute the squared distance between two line segments.
a_real a_line2_max(a_line2 const *ctx)
get the maximum length of the line segment.
void a_line2_set_org(a_line2 *ctx, a_real x, a_real y)
set the origin coordinates of the line.
int a_line2_setv(a_line2 *ctx, a_point2 const *p, a_vector2 const *v)
initialize the line segment from a start point and a direction vector.
void a_line2_rot_(a_line2 const *ctx, a_point2 const *rhs, a_real sin, a_real cos, a_line2 *res)
rotate a line segment around a pivot point using pre-calculated sine and cosine values.
a_real a_line2_dist(a_line2 const *ctx, a_point2 const *rhs)
compute the absolute distance from a point to the infinite line.
a_real a_line2_limdist2(a_line2 const *ctx, a_real min, a_real max, a_point2 const *rhs, a_real *w, a_point2 *p)
compute the squared distance from a point to the closest point on a line segment.
int a_line2_set(a_line2 *ctx, a_point2 const *p, a_point2 const *q)
initialize the line segment from two points (start point p, end point q).
int a_line2_set_tgt(a_line2 *ctx, a_real x, a_real y)
Set the line direction and length based on a target point relative to the current origin.
void a_line2_rot(a_line2 const *ctx, a_point2 const *rhs, a_real angle, a_line2 *res)
rotate a line segment around a specified pivot point.
a_point2 const * a_line2_org(a_line2 const *ctx)
get the address of the origin point of the line.
a_vector2 const * a_line2_dir(a_line2 const *ctx)
get the address of the direction vector of the line.
a_real a_line2_parm(a_line2 const *ctx, a_point2 const *rhs)
compute the scalar projection parameter of a point onto the infinite line.
int a_line2_set_dir(a_line2 *ctx, a_real x, a_real y)
set the direction vector and length of the line using raw components.
a_real a_line2_limparm(a_line2 const *ctx, a_real min, a_real max, a_point2 const *rhs)
compute the scalar projection parameter of a point onto the line segment.
a_real a_line2_limproj(a_line2 const *ctx, a_real min, a_real max, a_point2 const *rhs, a_point2 *res)
project a point onto a line segment.
void a_line2_tgt(a_line2 const *ctx, a_point2 *res)
compute the target endpoint of the line segment.
a_real a_line2_limdist(a_line2 const *ctx, a_real min, a_real max, a_point2 const *rhs, a_real *w, a_point2 *p)
compute the distance from a point to the closest point on a line segment.
int a_line2_int0(a_line2 const *ctx, a_real min, a_real max, a_point2 const *rhs, a_real *w)
compute the intersection between a point and a line segment.
int a_line2_int1(a_line2 const *ctx, a_real min1, a_real max1, a_line2 const *rhs, a_real min2, a_real max2, a_real *w1, a_real *w2)
compute the intersection between two line segments.
a_real a_line2_sdist(a_line2 const *ctx, a_point2 const *rhs)
compute the signed distance from a point to the infinite line.
a_real a_line2_proj(a_line2 const *ctx, a_point2 const *rhs, a_point2 *res)
project a point onto the infinite line.
void a_line2_set_max(a_line2 *ctx, a_real max)
set the maximum length of the line segment.
double a_real
compiler built-in floating-point number type
Definition a.h:1012
instance structure for two-dimensional line defined by an origin, a direction vector,...
Definition line2.h:294
a_real segdist2(a_real min1, a_real max1, a_line2 const &rhs, a_real min2, a_real max2, a_real &w1, a_point2 &p1, a_real &w2, a_point2 &p2) const
compute the squared distance between two line segments.
Definition line2.h:382
int set(a_point2 const &p, a_point2 const &q)
initialize the line segment from two points (start point p, end point q).
Definition line2.h:326
int int1(a_real min1, a_real max1, a_line2 const &rhs, a_real min2, a_real max2, a_real &w1, a_real &w2) const
compute the intersection between two line segments.
Definition line2.h:393
a_real sdist(a_point2 const &rhs) const
compute the signed distance from a point to the infinite line.
Definition line2.h:356
a_real dist(a_point2 const &rhs) const
compute the absolute distance from a point to the infinite line.
Definition line2.h:361
a_real proj(a_point2 const &rhs, a_point2 &res) const
project a point onto the infinite line.
Definition line2.h:341
void rot(a_point2 const &rhs, a_real angle, a_line2 &res) const
rotate a line segment around a specified pivot point.
Definition line2.h:404
a_real limdist2(a_real min_, a_real max_, a_point2 const &rhs, a_real &w, a_point2 &p)
compute the squared distance from a point to the closest point on a line segment.
Definition line2.h:371
int set_tgt(a_real x, a_real y)
Set the line direction and length based on a target point relative to the current origin.
Definition line2.h:316
int set(a_point2 const &p, a_vector2 const &v)
initialize the line segment from a start point and a direction vector.
Definition line2.h:321
a_vector2 const & dir() const
get the address of the direction vector of the line.
Definition line2.h:307
int set_dir(a_real x, a_real y)
set the direction vector and length of the line using raw components.
Definition line2.h:309
a_real segdist(a_real min1, a_real max1, a_line2 const &rhs, a_real min2, a_real max2, a_real &w1, a_point2 &p1, a_real &w2, a_point2 &p2) const
compute the distance between two line segments.
Definition line2.h:376
void set_org(a_real x, a_real y)
set the origin coordinates of the line.
Definition line2.h:302
void set_max(a_real max_)
set the maximum length of the line segment.
Definition line2.h:300
void eval(a_real w, a_point2 &res) const
evaluate a point on the line at a given parameter.
Definition line2.h:331
a_real limdist(a_real min_, a_real max_, a_point2 const &rhs, a_real &w, a_point2 &p)
compute the distance from a point to the closest point on a line segment.
Definition line2.h:366
a_point2 org
Definition line2.h:295
a_real parm(a_point2 const &rhs) const
compute the scalar projection parameter of a point onto the infinite line.
Definition line2.h:336
void tgt(a_point2 &res) const
compute the target endpoint of the line segment.
Definition line2.h:314
a_real limproj(a_real min_, a_real max_, a_point2 const &rhs, a_point2 &res) const
project a point onto a line segment.
Definition line2.h:351
a_real limparm(a_real min_, a_real max_, a_point2 const &rhs) const
compute the scalar projection parameter of a point onto the line segment.
Definition line2.h:346
a_vector2 dir_
Definition line2.h:296
void rot(a_point2 const &rhs, a_real sin, a_real cos, a_line2 &res) const
rotate a line segment around a pivot point using pre-calculated sine and cosine values.
Definition line2.h:399
a_real max
Definition line2.h:297
int int0(a_real min_, a_real max_, a_point2 const &rhs, a_real &w) const
compute the intersection between a point and a line segment.
Definition line2.h:388
instance structure for two-dimensional point
Definition point2.h:264
instance structure for two-dimensional vector
Definition vector2.h:343