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

Data Structures

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

Macros

#define a_line3_c(x)
#define a_line3_(_, x)

Typedefs

typedef struct a_line3 a_line3

Functions

a_real a_line3_max (a_line3 const *ctx)
 get the maximum length of the line segment.
a_point3 const * a_line3_org (a_line3 const *ctx)
 get the address of the origin point of the line.
a_vector3 const * a_line3_dir (a_line3 const *ctx)
 get the address of the direction vector of the line.
void a_line3_tgt (a_line3 const *ctx, a_point3 *res)
 compute the target endpoint of the line segment.
void a_line3_set_org (a_line3 *ctx, a_real x, a_real y, a_real z)
 set the origin coordinates of the line.
void a_line3_set_max (a_line3 *ctx, a_real max)
 set the maximum length of the line segment.
int a_line3_set_dir (a_line3 *ctx, a_real x, a_real y, a_real z)
 set the direction vector and length of the line using raw components.
int a_line3_set_tgt (a_line3 *ctx, a_real x, a_real y, a_real z)
 Set the line direction and length based on a target point relative to the current origin.
int a_line3_setv (a_line3 *ctx, a_point3 const *p, a_vector3 const *v)
 initialize the line segment from a start point and a direction vector.
int a_line3_set (a_line3 *ctx, a_point3 const *p, a_point3 const *q)
 initialize the line segment from two points (start point p, end point q).
void a_line3_eval (a_line3 const *ctx, a_real w, a_point3 *res)
 evaluate a point on the line at a given parameter.
a_real a_line3_parm (a_line3 const *ctx, a_point3 const *rhs)
 compute the scalar projection parameter of a point onto the infinite line.
a_real a_line3_proj (a_line3 const *ctx, a_point3 const *rhs, a_point3 *res)
 project a point onto the infinite line.
a_real a_line3_limparm (a_line3 const *ctx, a_real min, a_real max, a_point3 const *rhs)
 compute the scalar projection parameter of a point onto the line segment.
a_real a_line3_limproj (a_line3 const *ctx, a_real min, a_real max, a_point3 const *rhs, a_point3 *res)
 project a point onto a line segment.
a_real a_line3_dist (a_line3 const *ctx, a_point3 const *rhs)
 compute the distance from a point to the infinite line.
a_real a_line3_dist2 (a_line3 const *ctx, a_point3 const *rhs)
 compute the squared distance from a point to the infinite line.
a_real a_line3_limdist (a_line3 const *ctx, a_real min, a_real max, a_point3 const *rhs, a_real *w, a_point3 *p)
 compute the distance from a point to the closest point on a line segment.
a_real a_line3_limdist2 (a_line3 const *ctx, a_real min, a_real max, a_point3 const *rhs, a_real *w, a_point3 *p)
 compute the squared distance from a point to the closest point on a line segment.
a_real a_line3_segdist (a_line3 const *ctx, a_real min1, a_real max1, a_line3 const *rhs, a_real min2, a_real max2, a_real *w1, a_point3 *p1, a_real *w2, a_point3 *p2)
 compute the distance between two line segments.
a_real a_line3_segdist2 (a_line3 const *ctx, a_real min1, a_real max1, a_line3 const *rhs, a_real min2, a_real max2, a_real *w1, a_point3 *p1, a_real *w2, a_point3 *p2)
 compute the squared distance between two line segments.
int a_line3_int0 (a_line3 const *ctx, a_real min, a_real max, a_point3 const *rhs, a_real *w)
 compute the intersection between a point and a line segment.
int a_line3_int1 (a_line3 const *ctx, a_real min1, a_real max1, a_line3 const *rhs, a_real min2, a_real max2, a_real *w1, a_real *w2)
 compute the intersection between two line segments.
void a_line3_rot_ (a_line3 const *ctx, a_line3 const *rhs, a_real sin, a_real cos, a_line3 *res)
 rotate a 3D line segment around an arbitrary axis defined by another line.
void a_line3_rot (a_line3 const *ctx, a_line3 const *rhs, a_real angle, a_line3 *res)
 rotate a 3D line segment around an arbitrary axis defined by another line.

Detailed Description

Macro Definition Documentation

◆ a_line3_

#define a_line3_ ( _,
x )
Value:
a_cast_s(a_line3 _, x)
instance structure for three-dimensional line defined by an origin, a direction vector,...
Definition line3.h:297

◆ a_line3_c

#define a_line3_c ( x)

Function Documentation

◆ a_line3_dir()

a_vector3 const * a_line3_dir ( a_line3 const * ctx)

get the address of the direction vector of the line.

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

◆ a_line3_dist()

a_real a_line3_dist ( a_line3 const * ctx,
a_point3 const * rhs )

compute the distance from a point to the infinite line.

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

◆ a_line3_dist2()

a_real a_line3_dist2 ( a_line3 const * ctx,
a_point3 const * rhs )

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

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

◆ a_line3_eval()

void a_line3_eval ( a_line3 const * ctx,
a_real w,
a_point3 * res )

evaluate a point on the line at a given parameter.

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

◆ a_line3_int0()

int a_line3_int0 ( a_line3 const * ctx,
a_real min,
a_real max,
a_point3 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_line3_int1()

int a_line3_int1 ( a_line3 const * ctx,
a_real min1,
a_real max1,
a_line3 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_line3_limdist()

a_real a_line3_limdist ( a_line3 const * ctx,
a_real min,
a_real max,
a_point3 const * rhs,
a_real * w,
a_point3 * 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_line3_limdist2()

a_real a_line3_limdist2 ( a_line3 const * ctx,
a_real min,
a_real max,
a_point3 const * rhs,
a_real * w,
a_point3 * 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_line3_limparm()

a_real a_line3_limparm ( a_line3 const * ctx,
a_real min,
a_real max,
a_point3 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_line3_limproj()

a_real a_line3_limproj ( a_line3 const * ctx,
a_real min,
a_real max,
a_point3 const * rhs,
a_point3 * 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_line3_max()

a_real a_line3_max ( a_line3 const * ctx)

get the maximum length of the line segment.

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

◆ a_line3_org()

a_point3 const * a_line3_org ( a_line3 const * ctx)

get the address of the origin point of the line.

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

◆ a_line3_parm()

a_real a_line3_parm ( a_line3 const * ctx,
a_point3 const * rhs )

compute the scalar projection parameter of a point onto the infinite line.

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

◆ a_line3_proj()

a_real a_line3_proj ( a_line3 const * ctx,
a_point3 const * rhs,
a_point3 * res )

project a point onto the infinite line.

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

◆ a_line3_rot()

void a_line3_rot ( a_line3 const * ctx,
a_line3 const * rhs,
a_real angle,
a_line3 * res )

rotate a 3D line segment around an arbitrary axis defined by another line.

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

◆ a_line3_rot_()

void a_line3_rot_ ( a_line3 const * ctx,
a_line3 const * rhs,
a_real sin,
a_real cos,
a_line3 * res )

rotate a 3D line segment around an arbitrary axis defined by another line.

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

◆ a_line3_segdist()

a_real a_line3_segdist ( a_line3 const * ctx,
a_real min1,
a_real max1,
a_line3 const * rhs,
a_real min2,
a_real max2,
a_real * w1,
a_point3 * p1,
a_real * w2,
a_point3 * 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_line3_segdist2()

a_real a_line3_segdist2 ( a_line3 const * ctx,
a_real min1,
a_real max1,
a_line3 const * rhs,
a_real min2,
a_real max2,
a_real * w1,
a_point3 * p1,
a_real * w2,
a_point3 * 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_line3_set()

int a_line3_set ( a_line3 * ctx,
a_point3 const * p,
a_point3 const * q )

initialize the line segment from two points (start point p, end point q).

Parameters
[in,out]ctxpoints to an instance of the three-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_line3_set_dir()

int a_line3_set_dir ( a_line3 * ctx,
a_real x,
a_real y,
a_real z )

set the direction vector and length of the line using raw components.

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

◆ a_line3_set_max()

void a_line3_set_max ( a_line3 * ctx,
a_real max )

set the maximum length of the line segment.

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

◆ a_line3_set_org()

void a_line3_set_org ( a_line3 * ctx,
a_real x,
a_real y,
a_real z )

set the origin coordinates of the line.

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

◆ a_line3_set_tgt()

int a_line3_set_tgt ( a_line3 * ctx,
a_real x,
a_real y,
a_real z )

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 three-dimensional line
[in]xis X coordinate of the target point
[in]yis Y coordinate of the target point
[in]zis Z coordinate of the target point
Returns
error code value
Return values
<0failure
0success

◆ a_line3_setv()

int a_line3_setv ( a_line3 * ctx,
a_point3 const * p,
a_vector3 const * v )

initialize the line segment from a start point and a direction vector.

Parameters
[in,out]ctxpoints to an instance of the three-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_line3_tgt()

void a_line3_tgt ( a_line3 const * ctx,
a_point3 * res )

compute the target endpoint of the line segment.

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