Antiprism 0.23

- Main Page
- Classes
- Files

- File List
- File Members

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:

  v0 | vector to rotate (perpendicular to axis)
  v1 | vector to rotate onto (perpendicular to axis)
  axis | axis 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:

  pts | the points
  idxs | the 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:

  verts | a set of vertices
  face | the index numbers of the vertices in verts that make the face.
  allow_zero | if `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:

  Q | a point on the plane.
  n | the normal to the plane
  P0 | a point on the line
  P1 | a second point on the line
  where | to 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
  eps | value 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:

  Q0 | a point on the plane.
  Q1 | a second point on the plane.
  Q2 | a third points on the plane, not on the line Q0Q1.
  P0 | a point on the line
  P1 | a second point on the line
  where | to 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
  eps | value 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:

  P0 | a point on the first line.
  P1 | another point on the first line.
  Q0 | a point on the second line.
  Q1 | another point on the second line.
  eps | value 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:

  P0 | a point on the first line.
  P1 | another point on the first line.
  Q0 | a point on the second line.
  Q1 | another point on the second line.
  P | to return the nearest point on the first line.
  Q | to return the nearest point on the second line.
  eps | value 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:

  P | a point.
  Q0 | a point on the plane.
  Q1 | a second point on the plane.
  Q2 | a third points on the plane, not on the line Q0Q1.
  eps | value 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:

  P | a point.
  points | independant points determining the space (one, two or three points as the space is a point, line or plane.)
  eps | value 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:

  P | a point.
  Q0 | a point on the line.
  Q1 | another 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:

  P | a point.
  points | a set of points.
  idxs | the 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.)
  eps | value 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:

  Q0 | a point on the first plane.
  n0 | the normal to the first plane.
  Q1 | a point on the second plane.
  n1 | the normal to the second plane.
  P | to return a point on the line of intersection.
  dir | to return the direction of the line of intersection.
  eps | value for contolling the limit of precision

Returns:
  `true` if the planes intersect, otherwise `false`.