- Main Page
- Modules
- Classes
- Files
- Related Pages

- File List
- File Members

# src/vectorMath/VectorMath.h File Reference

`#include "../config.h"`
`#include <math.h>`
`#include "mathex.h"`
`#include "vmath.h"`
`#include "../typedefs.h"`

Go to the source code of this file.

## Enumerations
enum | IntersectResult { PARALLEL, COINCIDENT, NOT_INTERESECTING, INTERESECTING }
## Functions
int | randomIntInRange (int lowest, int highest)
Vector3r | midPoint (const Vector3r &a, const Vector3r &b)
Vector3r | midPoint (const dReal *a, const dReal *b)
Vector3r | midPoint (const Line &l)
IntersectResult | intersect (const Line &l1, const Line &l2, Vector3r &intersection)
IntersectResult | intersect (const Vector3r &l1a, const Vector3r &l1b, const Vector3r &l2a, const Vector3r &l2b, Vector3r &intersection)
unsigned | IntersectPolygon (const Polygon &p, const Line &l, Vector3r *intersections, unsigned *intersected)
unsigned | IntersectPolygon (const Polygon *p, const Line &l, Vector3r *intersections, unsigned *intersected)
unsigned | IntersectPolygon (const Polygon &p, const Vector3r &la, const Vector3r &lb, Vector3r *intersections, unsigned *intersected)
unsigned | IntersectPolygon (const Polygon *p, const Vector3r &la, const Vector3r &lb, Vector3r *intersections, unsigned *intersected)
dReal | orientedDistFromLine (const Line &l, const Vector3r p)
bool | pointInPolygon (const Polygon &polygon, const Vector3r &point)

## Enumeration Type Documentation

enum IntersectResult

Types of line-to-line relation

Enumerator:

  PARALLEL |
  COINCIDENT |
  NOT_INTERESECTING |
  INTERESECTING |

## Function Documentation

IntersectResult intersect | ( | const Vector3r & | l1a,
|  | const Vector3r & | l1b,
|  | const Vector3r & | l2a,
|  | const Vector3r & | l2b,
|  | Vector3r & | intersection |
| ) |  |  |

Finds intersection of a line with another line

Parameters:

  | l1 | the first line
  | l2 | the second line
  | intersection | gets filled with the intersection coordinates, if any

Returns:
  the state of the two lines one to each other

IntersectResult intersect | ( | const Line & | l1,
|  | const Line & | l2,
|  | Vector3r & | intersection |
| ) |  |  |

Finds intersection of a line with another line

Parameters:

  | l1 | the first line
  | l2 | the second line
  | intersection | gets filled with the intersection coordinates, if any

Returns:
  the state of the two lines one to each other

unsigned IntersectPolygon | ( | const Polygon * | p,
|  | const Vector3r & | la,
|  | const Vector3r & | lb,
|  | Vector3r * | intersections,
|  | unsigned * | intersected |
| ) |  |  |

Finds all intersections of line with a polygon

Parameters:

  | p | the polygon
  | l | the line
  | intersections |
  | indexes | of the intersected polygon segments

Returns:
  number of the intersections found, at max 32

unsigned IntersectPolygon | ( | const Polygon & | p,
|  | const Vector3r & | la,
|  | const Vector3r & | lb,
|  | Vector3r * | intersections,
|  | unsigned * | intersected |
| ) |  |  |

Finds all intersections of line with a polygon

Parameters:

  | p | the polygon
  | l | the line
  | intersections |
  | indexes | of the intersected polygon segments

Returns:
  number of the intersections found, at max 32

unsigned IntersectPolygon | ( | const Polygon * | p,
|  | const Line & | l,
|  | Vector3r * | intersections,
|  | unsigned * | intersected |
| ) |  |  |

Finds all intersections of line with a polygon

Parameters:

  | p | the polygon
  | l | the line
  | intersections |
  | indexes | of the intersected polygon segments

Returns:
  number of the intersections found, at max 32

unsigned IntersectPolygon | ( | const Polygon & | p,
|  | const Line & | l,
|  | Vector3r * | intersections,
|  | unsigned * | intersected |
| ) |  |  |

Finds all intersections of line with a polygon

Parameters:

  | p | the polygon
  | l | the line
  | intersections |
  | indexes | of the intersected polygon segments

Returns:
  number of the intersections found, at max 32

Vector3r midPoint | ( | const Line & | l | ) | `[inline]`

Gives the point in the middle of a line

Vector3r midPoint | ( | const dReal * | a,
|  | const dReal * | b |
| ) |  |  | `[inline]`

Gives the point in the middle of a line formed by the A and B points

Vector3r midPoint | ( | const Vector3r & | a,
|  | const Vector3r & | b |
| ) |  |  | `[inline]`

Gives the point in the middle of a line formed by the A and B points

dReal orientedDistFromLine | ( | const Line & | l,
|  | const Vector3r | p |
| ) |  |  |

Returns oriented distance of a point from line. Oriented means the result is: > 0 if the point P lies on the right of the line, taken by the orientation of the line < 0 if the point P lies on the left of the line, taken by the orientation of the line

bool pointInPolygon | ( | const Polygon & | polygon,
|  | const Vector3r & | point |
| ) |  |  |

Finds if point lies within the polygon using the ray tracing method

int randomIntInRange | ( | int | lowest,
|  | int | highest |
| ) |  |  |

Gives random integer number in the range lowest-highest number