SclGetTriangleIntersections
Overview
Find the points of intersection between a line segment and trisolation.
Synopsis
$triangleHandle SclGetTriangleIntersections $x1 $y1 $z1 $x2 $y2 $z2 xint yint zint
$triangleHandle SclGetTriangleIntersections $triangleIndex1 $x1 $y1 $z1 $triangleIndex2 $x2 $y2 $z2 xint yint zint
Description
This function permits you to find the points of intersection between a line segment and a trisolation. The line segment is defined by start and end points, whose coordinates are specified by x1, y1, z1 and x2, y2, z2 respectively.
The intersected trisolation must be a surface, not a solid.
Arguments
- triangleIndex1, triangleIndex2
- x1, y1, z1
- x2, y2, z2
- xint, yint, zint
Pass by value. The indices of the triangles containing the start and end points of the intersecting line segment. To determine the triangle index of a point use the SclFindTriangle extension, passing the coordinates of the intersecting line's start or end point as arguments. These arguments are optional, however, if SclGetTriangleIntersections is called repeatedly then specifying these values can improve performance if a triangle index can be cached between calls to SclGetTriangleIntersections.
Pass by value. Coordinates of the line segment's start point.
Pass by value. Coordinates of the line segment's end point.
Pass by reference. Lists containing the x, y and z coordinates for every point of intersection found between the specified line segment and trisolation.
Returns
An integer value indicating the number of intersections found between the line segment and trisolation. This value matches the number of coordinates stored in the list variables xint, yint and zint.
If no points of intersection were found then zero is returned and xint, yint and zint will be empty list variables.
Examples
set triIndex1 0
set triIndex2 0
set valid_tri false
if {[$trisol SclFindTriangle triIndex1 $x1 $y1 ztri1 desc1]} {
if {[$trisol SclFindTriangle triIndex2 $x2 $y2 ztri2 desc2]} {
set valid_tri true
}
}
if {$valid_tri} {
if {[catch {set num_ints [$trisol SclGetTriangleIntersections \
$triIndex1 $x1 $y1 $z1 $triIndex2 $x2 $y2 $z2 xint yint zint]}] == 0} {
for {set j 0} {$j < $num_ints} {incr j} {
puts "Point of intersection: x=[lindex $xint $j], y=[lindex $yint $j], z=[lindex $zint $j]"
}
}
}
|