Antiprism 0.23
Functions

base/vec_utils.h File Reference

Vector utilities. More...

#include <vector>
#include "vec3d.h"
Include dependency graph for vec_utils.h:
This graph shows which files directly or indirectly include this file:

Functions

vec3d centroid (const vector< vec3d > &pts, const vector< int > &idxs=vector< int >())
 Get the centroid of a set of points.
vec3d line_plane_intersect (vec3d Q, vec3d n, vec3d P0, vec3d P1, int *where=0, double eps=epsilon)
 Get the point of intersection of a line and a plane.
vec3d line_plane_intersect (vec3d Q0, vec3d Q1, vec3d Q2, vec3d P0, vec3d P1, int *where=0, double eps=epsilon)
 Get the point of intersection of a line and a plane.
bool two_plane_intersect (vec3d Q0, vec3d n0, vec3d Q1, vec3d n1, vec3d &P, vec3d &dir, double eps=epsilon)
 Get the line where two planes intersect.
bool lines_nearest_points (vec3d P0, vec3d P1, vec3d Q0, vec3d Q1, vec3d &P, vec3d &Q, double eps=epsilon)
 Get the nearest point on a line to another (skew) line.
vec3d nearest_point (vec3d P, vec3d Q0, vec3d Q1)
 Get the nearest point on a line to a particular point.
vec3d nearest_point (vec3d P, vec3d Q0, vec3d Q1, vec3d Q2, double eps=epsilon)
 Get the nearest point on a plane to a particular point.
vec3d nearest_point (vec3d P, const vector< vec3d > &points, double eps=epsilon)
 Get the nearest point on a space to a particular point.
vec3d nearest_point (vec3d P, const vector< vec3d > &points, const vector< int > &idxs, double eps=epsilon)
 Get the nearest point on a space to a particular point.
vec3d face_norm (const vector< vec3d > &verts, const vector< int > &face, bool allow_zero=false)
 Get a face normal and face area.
double angle_around_axis (const vec3d &v0, const vec3d &v1, const vec3d &axis)
 Get the angle required to rotate one vector onto another around an axis.
vec3d lines_intersection (const vec3d &P0, const vec3d &P1, const vec3d &Q0, const vec3d &Q1, double eps=epsilon)
 Get the point of intersection between two lines.

Detailed Description

Vector utilities.


Function Documentation

double angle_around_axis ( const vec3d v0,
const vec3d v1,
const vec3d axis 
)

Get the angle required to rotate one vector onto another around an axis.

Parameters:
v0vector to rotate (perpendicular to axis)
v1vector to rotate onto (perpendicular to axis)
axisaxis to rotate around (perpendicular to v0 and v1)
Returns:
angle, in range 0 <= ang < 2PI
vec3d centroid ( const vector< vec3d > &  pts,
const vector< int > &  idxs = vector< int >() 
)

Get the centroid of a set of points.

Parameters:
ptsthe points
idxsthe index numbers of the points to use, or if none (the default) then use all the points.
Returns:
The centroid.
vec3d face_norm ( const vector< vec3d > &  verts,
const vector< int > &  face,
bool  allow_zero = false 
)

Get a face normal and face area.

Parameters:
vertsa set of vertices
facethe index numbers of the vertices in verts that make the face.
allow_zeroif true then the length of the returned normal is the area of the face, if false then this will not be true for faces with a signed area close to zero.
Returns:
A normal to the face.
vec3d line_plane_intersect ( vec3d  Q,
vec3d  n,
vec3d  P0,
vec3d  P1,
int *  where = 0,
double  eps = epsilon 
)

Get the point of intersection of a line and a plane.

Parameters:
Qa point on the plane.
nthe normal to the plane
P0a point on the line
P1a second point on the line
whereto return the the intersection point was relative to the two points on the line, the meaning of the values is

  • 0 - outside P0
  • 1 - on P0
  • 2 - between P0 and P1
  • 3 - on P1
  • 4 - outside P1
epsvalue for contolling the limit of precision
Returns:
the point of intersection (it will be unset if the line doesn't intersect the plane.
vec3d line_plane_intersect ( vec3d  Q0,
vec3d  Q1,
vec3d  Q2,
vec3d  P0,
vec3d  P1,
int *  where = 0,
double  eps = epsilon 
)

Get the point of intersection of a line and a plane.

Parameters:
Q0a point on the plane.
Q1a second point on the plane.
Q2a third points on the plane, not on the line Q0Q1.
P0a point on the line
P1a second point on the line
whereto return the the intersection point was relative to the two points on the line, the meaning of the values is

  • 0 - outside P0
  • 1 - on P0
  • 2 - between P0 and P1
  • 3 - on P1
  • 4 - outside P1
epsvalue for contolling the limit of precision
Returns:
The point of intersection (it will be unset if the line doesn't intersect the plane
vec3d lines_intersection ( const vec3d P0,
const vec3d P1,
const vec3d Q0,
const vec3d Q1,
double  eps = epsilon 
)

Get the point of intersection between two lines.

Parameters:
P0a point on the first line.
P1another point on the first line.
Q0a point on the second line.
Q1another point on the second line.
epsvalue for controlling the limit of precision. If eps is 0 then always return an intersection point, even if lines are skew or parallel.
Returns:
The point of intersection (it will be unset if eps>0 and the point is not within distance eps from both lines
bool lines_nearest_points ( vec3d  P0,
vec3d  P1,
vec3d  Q0,
vec3d  Q1,
vec3d P,
vec3d Q,
double  eps = epsilon 
)

Get the nearest point on a line to another (skew) line.

Parameters:
P0a point on the first line.
P1another point on the first line.
Q0a point on the second line.
Q1another point on the second line.
Pto return the nearest point on the first line.
Qto return the nearest point on the second line.
epsvalue for contolling the limit of precision
Returns:
true if there is one nesarpoint per line, otherwise false (the lines are parallel.)
vec3d nearest_point ( vec3d  P,
vec3d  Q0,
vec3d  Q1,
vec3d  Q2,
double  eps = epsilon 
)

Get the nearest point on a plane to a particular point.

Parameters:
Pa point.
Q0a point on the plane.
Q1a second point on the plane.
Q2a third points on the plane, not on the line Q0Q1.
epsvalue for contolling the limit of precision
Returns:
The point on the plane through Q0, Q1 and Q2 that is closest to P.
vec3d nearest_point ( vec3d  P,
const vector< vec3d > &  points,
double  eps = epsilon 
)

Get the nearest point on a space to a particular point.

Parameters:
Pa point.
pointsindependant points determining the space (one, two or three points as the space is a point, line or plane.)
epsvalue for contolling the limit of precision
Returns:
The point on the space that is closest to P.
vec3d nearest_point ( vec3d  P,
vec3d  Q0,
vec3d  Q1 
) [inline]

Get the nearest point on a line to a particular point.

Parameters:
Pa point.
Q0a point on the line.
Q1another point on the line.
Returns:
The point on the line through Q0 and Q1 that is closest to P.
vec3d nearest_point ( vec3d  P,
const vector< vec3d > &  points,
const vector< int > &  idxs,
double  eps = epsilon 
)

Get the nearest point on a space to a particular point.

Parameters:
Pa point.
pointsa set of points.
idxsthe index numbers of independant points from points that determine the space (one, two or three index numbers as the space is a point, line or plane.)
epsvalue for contolling the limit of precision
Returns:
The point on the space that is closest to P.
bool two_plane_intersect ( vec3d  Q0,
vec3d  n0,
vec3d  Q1,
vec3d  n1,
vec3d P,
vec3d dir,
double  eps = epsilon 
)

Get the line where two planes intersect.

Parameters:
Q0a point on the first plane.
n0the normal to the first plane.
Q1a point on the second plane.
n1the normal to the second plane.
Pto return a point on the line of intersection.
dirto return the direction of the line of intersection.
epsvalue for contolling the limit of precision
Returns:
true if the planes intersect, otherwise false.