liba 0.1.15
An algorithm library based on C/C++
Loading...
Searching...
No Matches
two-dimensional line defined by an origin, a direction vector, and a length
Collaboration diagram for two-dimensional line defined by an origin, a direction vector, and a length:

Data Structures

struct  a_line2
 instance structure for two-dimensional line defined by an origin, a direction vector, and a length More...

Macros

#define a_line2_c(x)
#define a_line2_(_, x)

Typedefs

typedef struct a_line2 a_line2

Functions

a_real a_line2_max (a_line2 const *ctx)
 get the maximum length of the line segment.
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.
void a_line2_tgt (a_line2 const *ctx, a_point2 *res)
 compute the target endpoint 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.
void a_line2_set_max (a_line2 *ctx, a_real max)
 set the maximum length of the line segment.
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.
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.
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.
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).
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_parm (a_line2 const *ctx, a_point2 const *rhs)
 compute the scalar projection parameter of a point onto 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.
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.
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_dist (a_line2 const *ctx, a_point2 const *rhs)
 compute the absolute distance from a point to the infinite line.
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.
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.
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.
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.
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.
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.
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.

Detailed Description

Macro Definition Documentation

◆ a_line2_

#define a_line2_ ( _,
x )
Value:
a_cast_s(a_line2 _, x)
instance structure for two-dimensional line defined by an origin, a direction vector,...
Definition line2.h:294

◆ a_line2_c

#define a_line2_c ( x)

Function Documentation

◆ a_line2_dir()

a_vector2 const * a_line2_dir ( a_line2 const * ctx)

get the address of the direction vector of the line.

Parameters
[in]ctxpoints to an instance of the two-dimensional line
Returns
the address of the direction vector

◆ a_line2_dist()

a_real a_line2_dist ( a_line2 const * ctx,
a_point2 const * rhs )

compute the absolute distance from a point to the infinite line.

Parameters
[in]ctxpoints to an instance of the two-dimensional line
[in]rhspoints to the point
Returns
the absolute distance

◆ a_line2_eval()

void a_line2_eval ( a_line2 const * ctx,
a_real w,
a_point2 * res )

evaluate a point on the line at a given parameter.

Parameters
[in]ctxpoints to an instance of the two-dimensional line
[in]wis the scalar parameter
[out]resstores the result

◆ a_line2_int0()

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.

Parameters
[in]ctxpoints to an instance of the line segment
[in]minis the lower bound of the line segment
[in]maxis the upper bound of the line segment
[in]rhspoints to the point to intersect
[out]wstores the parameter on the segment
Returns
the intersection type
Return values
1intersection found
0no intersection

◆ a_line2_int1()

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.

Parameters
[in]ctxpoints to an instance of the first line segment
[in]min1is the lower bound of the first line segment
[in]max1is the upper bound of the first line segment
[in]rhspoints to an instance of the second line segment
[in]min2is the lower bound of the second line segment
[in]max2is the upper bound of the second line segment
[out]w1stores parameter of the point on the first segment or the start point on the first segment
[out]w2stores parameter of the point on the second segment or the end point on the first segment
Returns
the intersection type
Return values
2intersection is a segment, the start point and the end point on the first segment
1intersection is a point, the point on the first segment and the second segment
0no intersection

◆ a_line2_limdist()

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.

Parameters
[in]ctxpoints to an instance of the line segment
[in]minis the lower bound of the line segment
[in]maxis the upper bound of the line segment
[in]rhspoints to the point
[out]wstores the parameter of the closest point
[out]pstores the coordinates of the closest point
Returns
the distance

◆ a_line2_limdist2()

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.

Parameters
[in]ctxpoints to an instance of the line segment
[in]minis the lower bound of the line segment
[in]maxis the upper bound of the line segment
[in]rhspoints to the point
[out]wstores the parameter of the closest point
[out]pstores the coordinates of the closest point
Returns
the squared distance

◆ a_line2_limparm()

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.

Parameters
[in]ctxpoints to an instance of the line segment
[in]minis the lower bound of the line segment
[in]maxis the upper bound of the line segment
[in]rhspoints to the point to project
Returns
the clamped scalar parameter

◆ a_line2_limproj()

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.

Parameters
[in]ctxpoints to an instance of the line segment
[in]minis the lower bound of the line segment
[in]maxis the upper bound of the line segment
[in]rhspoints to the point to project
[in]resstores the projection result
Returns
the clamped projection parameter

◆ a_line2_max()

a_real a_line2_max ( a_line2 const * ctx)

get the maximum length of the line segment.

Parameters
[in]ctxpoints to an instance of the two-dimensional line
Returns
the maximum length value

◆ a_line2_org()

a_point2 const * a_line2_org ( a_line2 const * ctx)

get the address of the origin point of the line.

Parameters
[in]ctxpoints to an instance of the two-dimensional line
Returns
the address of the origin point

◆ a_line2_parm()

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.

Parameters
[in]ctxpoints to an instance of the two-dimensional line
[in]rhspoints to the point to project
Returns
the scalar parameter

◆ a_line2_proj()

a_real a_line2_proj ( a_line2 const * ctx,
a_point2 const * rhs,
a_point2 * res )

project a point onto the infinite line.

Parameters
[in]ctxpoints to an instance of the two-dimensional line
[in]rhspoints to the point to project
[in]resstores the projection result
Returns
the projection parameter

◆ a_line2_rot()

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.

Parameters
[in]ctxpoints to an instance of the line segment
[in]rhspoints to the pivot point
[in]angleis rotation angle in radians
[out]resstores the result line segment

◆ a_line2_rot_()

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.

Parameters
[in]ctxpoints to an instance of the line segment
[in]rhspoints to the pivot point
[in]sinis precomputed \(\sin(\theta)\)
[in]cosis precomputed \(\cos(\theta)\)
[out]resstores the result line segment

◆ a_line2_sdist()

a_real a_line2_sdist ( a_line2 const * ctx,
a_point2 const * rhs )

compute the signed distance from a point to the infinite line.

Parameters
[in]ctxpoints to an instance of the two-dimensional line
[in]rhspoints to the point
Returns
the signed distance

◆ a_line2_segdist()

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.

Parameters
[in]ctxpoints to an instance of the first line segment
[in]min1is the lower bound of the first line segment
[in]max1is the upper bound of the first line segment
[in]rhspoints to an instance of the second line segment
[in]min2is the lower bound of the second line segment
[in]max2is the upper bound of the second line segment
[out]w1stores parameter of the closest point on the first segment
[out]p1stores coordinates of the closest point on the first segment
[out]w2stores parameter of the closest point on the second segment
[out]p2stores coordinates of the closest point on the second segment
Returns
the distance between the two segments

◆ a_line2_segdist2()

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.

Parameters
[in]ctxpoints to an instance of the first line segment
[in]min1is the lower bound of the first line segment
[in]max1is the upper bound of the first line segment
[in]rhspoints to an instance of the second line segment
[in]min2is the lower bound of the second line segment
[in]max2is the upper bound of the second line segment
[out]w1stores parameter of the closest point on the first segment
[out]p1stores coordinates of the closest point on the first segment
[out]w2stores parameter of the closest point on the second segment
[out]p2stores coordinates of the closest point on the second segment
Returns
the squared distance between the two segments

◆ a_line2_set()

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).

Parameters
[in,out]ctxpoints to an instance of the two-dimensional line
[in]ppoints to the start point (origin)
[in]qpoints to the end point (target)
Returns
error code value
Return values
<0failure
0success

◆ a_line2_set_dir()

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.

Parameters
[in,out]ctxpoints to an instance of the two-dimensional line
[in]xis X component of the direction vector
[in]yis Y component of the direction vector
Returns
error code value
Return values
<0failure
0success

◆ a_line2_set_max()

void a_line2_set_max ( a_line2 * ctx,
a_real max )

set the maximum length of the line segment.

Parameters
[in,out]ctxpoints to an instance of the two-dimensional line
[in]maxis the maximum length

◆ a_line2_set_org()

void a_line2_set_org ( a_line2 * ctx,
a_real x,
a_real y )

set the origin coordinates of the line.

Parameters
[in,out]ctxpoints to an instance of the two-dimensional line
[in]xis the x-coordinate of the origin
[in]yis the y-coordinate of the origin

◆ a_line2_set_tgt()

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.

Parameters
[in,out]ctxpoints to an instance of the two-dimensional line
[in]xis X coordinate of the target point
[in]yis Y coordinate of the target point
Returns
error code value
Return values
<0failure
0success

◆ a_line2_setv()

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.

Parameters
[in,out]ctxpoints to an instance of the two-dimensional line
[in]ppoints to the start point (origin)
[in]vpoints to the direction vector (defines direction and length)
Returns
error code value
Return values
<0failure
0success

◆ a_line2_tgt()

void a_line2_tgt ( a_line2 const * ctx,
a_point2 * res )

compute the target endpoint of the line segment.

Parameters
[in]ctxpoints to an instance of the two-dimensional line
[out]resstores the target endpoint of the line segment