Functions
core/vgl/vgl_triangle_3d.cxx File Reference

Some helpful functions when working with triangles. More...

#include "vgl_triangle_3d.h"
#include <vcl_limits.h>
#include <vgl/vgl_distance.h>
#include <vgl/vgl_intersection.h>
#include <vgl/vgl_line_3d_2_points.h>
#include <vgl/vgl_plane_3d.h>
#include <vgl/vgl_point_3d.h>
#include <vgl/vgl_vector_3d.h>
#include <vgl/vgl_closest_point.h>

Go to the source code of this file.

Functions

vcl_vector< vcl_pair< unsigned,
unsigned > > 
vgl_triangle_3d_coincident_edges (const vgl_point_3d< double > &a_p1, const vgl_point_3d< double > &a_p2, const vgl_point_3d< double > &a_p3, const vgl_point_3d< double > &b_p1, const vgl_point_3d< double > &b_p2, const vgl_point_3d< double > &b_p3)
 Check for coincident edges of triangles a and b.
bool vgl_triangle_3d_test_inside (const vgl_point_3d< double > &i_pnt, const vgl_point_3d< double > &p1, const vgl_point_3d< double > &p2, const vgl_point_3d< double > &p3)
 Check if the given point is inside the triangle.
bool vgl_triangle_3d_test_inside_simple (const vgl_point_3d< double > &i_pnt, const vgl_point_3d< double > &p1, const vgl_point_3d< double > &p2, const vgl_point_3d< double > &p3)
 Check if point i_pnt is inside the triangle.
vgl_triangle_3d_intersection_t vgl_triangle_3d_line_intersection (const vgl_line_segment_3d< double > &line, const vgl_point_3d< double > &p1, const vgl_point_3d< double > &p2, const vgl_point_3d< double > &p3, vgl_point_3d< double > &i_pnt, bool ignore_coplanar)
 Compute the intersection point between the line segment and triangle.
vgl_triangle_3d_intersection_t vgl_triangle_3d_triangle_intersection (const vgl_point_3d< double > &a_p1, const vgl_point_3d< double > &a_p2, const vgl_point_3d< double > &a_p3, const vgl_point_3d< double > &b_p1, const vgl_point_3d< double > &b_p2, const vgl_point_3d< double > &b_p3, vgl_line_segment_3d< double > &i_line)
 compute the intersection line of the given triangles.
vgl_triangle_3d_intersection_t vgl_triangle_3d_triangle_intersection (const vgl_point_3d< double > &a_p1, const vgl_point_3d< double > &a_p2, const vgl_point_3d< double > &a_p3, const vgl_point_3d< double > &b_p1, const vgl_point_3d< double > &b_p2, const vgl_point_3d< double > &b_p3)
 Compute if the given triangles a and b intersect.
vgl_triangle_3d_intersection_t vgl_triangle_3d_plane_intersection (const vgl_point_3d< double > &p1, const vgl_point_3d< double > &p2, const vgl_point_3d< double > &p3, const vgl_plane_3d< double > &i_plane, vgl_line_segment_3d< double > &i_line)
 Compute the line of intersection of the given triangle and plane.
vgl_point_3d< double > vgl_triangle_3d_closest_point (const vgl_point_3d< double > &q, const vgl_point_3d< double > &p1, const vgl_point_3d< double > &p2, const vgl_point_3d< double > &p3)
 Compute the closest point on a triangle to a reference point.
double vgl_triangle_3d_distance (const vgl_point_3d< double > &q, const vgl_point_3d< double > &p1, const vgl_point_3d< double > &p2, const vgl_point_3d< double > &p3)
 Compute the distance to the closest point on a triangle from a reference point.
bool vgl_triangle_3d_triangle_coplanar (const vgl_point_3d< double > &a_p1, const vgl_point_3d< double > &a_p2, const vgl_point_3d< double > &a_p3, const vgl_point_3d< double > &b_p1, const vgl_point_3d< double > &b_p2, const vgl_point_3d< double > &b_p3)
 Check if the two triangles are coplanar.
double vgl_triangle_3d_area (const vgl_point_3d< double > &p0, const vgl_point_3d< double > &p1, const vgl_point_3d< double > &p2)
 Compute the area of a triangle.
double vgl_triangle_3d_aspect_ratio (const vgl_point_3d< double > &p0, const vgl_point_3d< double > &p1, const vgl_point_3d< double > &p2)
 Compute the aspect ration of a triangle.

Detailed Description

Some helpful functions when working with triangles.

Author:
Kieran O'Mahony
Date:
21 June 2007

Definition in file vgl_triangle_3d.cxx.


Function Documentation

double vgl_triangle_3d_area ( const vgl_point_3d< double > &  p0,
const vgl_point_3d< double > &  p1,
const vgl_point_3d< double > &  p2 
)

Compute the area of a triangle.

The triangle is represented by its vertices p1, p2, p3

Definition at line 1303 of file vgl_triangle_3d.cxx.

double vgl_triangle_3d_aspect_ratio ( const vgl_point_3d< double > &  p0,
const vgl_point_3d< double > &  p1,
const vgl_point_3d< double > &  p2 
)

Compute the aspect ration of a triangle.

Compute the aspect ratio of a triangle.

The triangle is represented by its vertices p1, p2, p3

Definition at line 1325 of file vgl_triangle_3d.cxx.

vgl_point_3d<double> vgl_triangle_3d_closest_point ( const vgl_point_3d< double > &  q,
const vgl_point_3d< double > &  p1,
const vgl_point_3d< double > &  p2,
const vgl_point_3d< double > &  p3 
)

Compute the closest point on a triangle to a reference point.

The triangle is represented by its vertices p1, p2, p3.

Parameters:
qThe reference point.
Returns:
The closest point on the triangle. This may be inside the triangle, or it may be a point on one of the triangle edges.

Definition at line 1198 of file vgl_triangle_3d.cxx.

vcl_vector<vcl_pair<unsigned,unsigned> > vgl_triangle_3d_coincident_edges ( const vgl_point_3d< double > &  a_p1,
const vgl_point_3d< double > &  a_p2,
const vgl_point_3d< double > &  a_p3,
const vgl_point_3d< double > &  b_p1,
const vgl_point_3d< double > &  b_p2,
const vgl_point_3d< double > &  b_p3 
)

Check for coincident edges of triangles a and b.

Returns:
a vector of the coincident edges

Definition at line 26 of file vgl_triangle_3d.cxx.

double vgl_triangle_3d_distance ( const vgl_point_3d< double > &  q,
const vgl_point_3d< double > &  p1,
const vgl_point_3d< double > &  p2,
const vgl_point_3d< double > &  p3 
)

Compute the distance to the closest point on a triangle from a reference point.

The triangle is represented by its vertices p1, p2, p3.

Parameters:
qThe reference point.
Returns:
The distance to the closest point on the triangle. (The closest point may be inside the triangle, or it may be a point on one of the triangle edges.)

Definition at line 1274 of file vgl_triangle_3d.cxx.

vgl_triangle_3d_intersection_t vgl_triangle_3d_line_intersection ( const vgl_line_segment_3d< double > &  line,
const vgl_point_3d< double > &  p1,
const vgl_point_3d< double > &  p2,
const vgl_point_3d< double > &  p3,
vgl_point_3d< double > &  i_pnt,
bool  ignore_coplanar 
)

Compute the intersection point between the line segment and triangle.

The triangle is represented by its vertices p1, p2, p3

Returns:
intersection type

Definition at line 221 of file vgl_triangle_3d.cxx.

vgl_triangle_3d_intersection_t vgl_triangle_3d_plane_intersection ( const vgl_point_3d< double > &  p1,
const vgl_point_3d< double > &  p2,
const vgl_point_3d< double > &  p3,
const vgl_plane_3d< double > &  i_plane,
vgl_line_segment_3d< double > &  i_line 
)

Compute the line of intersection of the given triangle and plane.

The triangle is represented by its vertices p1, p2, p3

Returns:
intersection type
Note:
an intersection line is not defined (vgl_vgl_nan) for a coplanar intersection

Definition at line 1104 of file vgl_triangle_3d.cxx.

bool vgl_triangle_3d_test_inside ( const vgl_point_3d< double > &  i_pnt,
const vgl_point_3d< double > &  p1,
const vgl_point_3d< double > &  p2,
const vgl_point_3d< double > &  p3 
)

Check if the given point is inside the triangle.

The triangle is represented by its vertices p1, p2, p3

Returns:
true if point is inside

Definition at line 80 of file vgl_triangle_3d.cxx.

bool vgl_triangle_3d_test_inside_simple ( const vgl_point_3d< double > &  i_pnt,
const vgl_point_3d< double > &  p1,
const vgl_point_3d< double > &  p2,
const vgl_point_3d< double > &  p3 
)

Check if point i_pnt is inside the triangle.

The triangle is represented by its vertices p1, p2, p3

Returns:
true if point is inside
Note:
this method uses the less efficient 'angles' method which requires 3 calls to acos()

Definition at line 167 of file vgl_triangle_3d.cxx.

bool vgl_triangle_3d_triangle_coplanar ( const vgl_point_3d< double > &  a_p1,
const vgl_point_3d< double > &  a_p2,
const vgl_point_3d< double > &  a_p3,
const vgl_point_3d< double > &  b_p1,
const vgl_point_3d< double > &  b_p2,
const vgl_point_3d< double > &  b_p3 
)

Check if the two triangles are coplanar.

The triangles are represented by their respective vertices a_p1, a_p2, a_p3 and b_p1, b_p2, b_p3

Definition at line 1287 of file vgl_triangle_3d.cxx.

vgl_triangle_3d_intersection_t vgl_triangle_3d_triangle_intersection ( const vgl_point_3d< double > &  a_p1,
const vgl_point_3d< double > &  a_p2,
const vgl_point_3d< double > &  a_p3,
const vgl_point_3d< double > &  b_p1,
const vgl_point_3d< double > &  b_p2,
const vgl_point_3d< double > &  b_p3,
vgl_line_segment_3d< double > &  i_line 
)

compute the intersection line of the given triangles.

Compute the intersection line of the given triangles.

See also:
vgl_triangle_3d_triangle_intersection()
Note:
an intesection line is not computed for a coplanar intersection

Definition at line 327 of file vgl_triangle_3d.cxx.

vgl_triangle_3d_intersection_t vgl_triangle_3d_triangle_intersection ( const vgl_point_3d< double > &  a_p1,
const vgl_point_3d< double > &  a_p2,
const vgl_point_3d< double > &  a_p3,
const vgl_point_3d< double > &  b_p1,
const vgl_point_3d< double > &  b_p2,
const vgl_point_3d< double > &  b_p3 
)

Compute if the given triangles a and b intersect.

The triangle are represented by their respective vertices a_p1, a_p2, a_p3 and b_p1, b_p2, b_p3

Returns:
intersection type

Definition at line 754 of file vgl_triangle_3d.cxx.