Index of Functions: A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X 
Index Page
insang

Table of contents
Procedure
Abstract
Required_Reading
Keywords
Declarations
Brief_I/O
Detailed_Input
Detailed_Output
Parameters
Exceptions
Files
Particulars
Examples
Restrictions
Literature_References
Author_and_Institution
Version

Procedure

     INSANG ( Inside Tetrahedral Angle )

     SUBROUTINE INSANG ( V, E1, E2, E3, FOUND, SCALE )

Abstract

     Determine if a given vector lies inside the solid tetrahedral
     angle determined by 3 vectors. If it does, return the
     point where the scale factor such that SCALE*V lies in the
     plane spanned by E1, E2, and E3.

Required_Reading

     None.

Keywords

     VECTOR

Declarations

     IMPLICIT NONE

     DOUBLE PRECISION      V     ( 3 )
     DOUBLE PRECISION      E1    ( 3 )
     DOUBLE PRECISION      E2    ( 3 )
     DOUBLE PRECISION      E3    ( 3 )
     LOGICAL               FOUND
     DOUBLE PRECISION      SCALE

Brief_I/O

     VARIABLE  I/O  DESCRIPTION
     --------  ---  --------------------------------------------------
     V          I   Vector to test for "betweenness"
     E1         I   First edge of the tetrahedral angle
     E2         I   Second edge of the tetrahedral angle
     E3         I   Third edge of the tetrahedral angle
     FOUND      O   Indicates whether V lies in the solid angle
     SCALE      O   Scale times V is in the triangle E1,E2,E3

Detailed_Input

     V        is a 3-vector. This is the vector to test to see
              if it lies between the 3 vectors E1, E2 and E3

     E1,
     E2,
     E3       are the three edges of a solid tetrahedral angle. (See
              particulars for a discussion of the solid angle).

Detailed_Output

     FOUND    indicates that V lies inside the solid tetrahedral
              angle determined by E1, E2 and E3.


     SCALE    if V lies inside the solid tetrahedral angle given
              by E1, E2 and E3, SCALE*V is the point is the positive
              scalar multiple of V that pierces the triangle
              determined by the points E1, E2, E3.

Parameters

     None.

Exceptions

     Error free.

     1)  If E1, E2 and E3 are not linearly independent, the routine
         returns .FALSE. SCALE will be set to 0.

     2)  If V is the zero vector, the routine returns .FALSE.
         SCALE will be set to 0.

Files

     None.

Particulars

     Given 3 linearly independent vectors E1, E2, and E3 the
     set of vectors a*E1 + b*E2 + c*E3  where a, b, and c
     are non-negative form a region of space that is a tetrahedral
     solid angle. If you cut this solid angle with a plane
     that intersects all three rays from the origin determined
     by E1, E2 and E3 you will get a tetrahedron (a 4-sided
     solid with each face a triangle).

     This routine determines whether the ray associated with
     a vector V lies inside the tetrahedral angle E1,E2,E3.
     Moreover, if V lies inside this angle, this routine returns
     the scale factor SCALE such that the point SCALE*V
     lies in the plane containing the points E1, E2 and E3.
     This is necessarily a point in the triangle determined by
     E1, E2 and E3.

Examples

     Suppose you have a triangle in space specified by three
     vertices P1, P2 and P3 and that an observer at location
     OBS is looking along the ray emanating from OBS with
     direction V. Does this ray intersect the triangle
     P1, P2, P3?  Using this routine, you can answer this
     question and give the point of intersection if there is
     one. Here's how.

     First construct the vectors from OBS to the corners of
     the triangle.

     CALL VSUB ( P1, OBS, E1 )
     CALL VSUB ( P2, OBS, E2 )
     CALL VSUB ( P3, OBS, E3 )

     Now see if V lies between the vectors E1, E2, E3 and return
     the intersection point if it does.

     CALL INSANG ( V, E1, E2, E3, FOUND, SCALE )

     If there was an intersection, add SCALE*V to OBS to get the
     point of intersection. Otherwise say there was no intersection.

     IF ( FOUND ) THEN

        CALL VLCOM ( 1.0D0, OBS, SCALE, V, POINT )

        WRITE (*,*) 'The ray intersects the triangle at:
        WRITE (*,*) POINT(1)
        WRITE (*,*) POINT(2)
        WRITE (*,*) POINT(3)

     ELSE

        WRITE (*,*) 'There is no intersection.'

     END IF

Restrictions

     1)  This routine can suffer from extreme loss of precision if the
         vectors E1, E2, E3 are too long compared to the lengths of the
         line segments formed by their pairwise differences.

         The user of this routine must ensure that the inputs are
         suitable.

Literature_References

     None.

Author_and_Institution

     N.J. Bachman       (JPL)
     J. Diaz del Rio    (ODC Space)
     W.L. Taber         (JPL)

Version

    SPICELIB Version 1.0.3, 12-AUG-2021 (JDR)

        Edited the header to comply with NAIF standard.

    SPICELIB Version 1.0.2, 02-FEB-2016 (NJB)

        Fixed comment typos. Updated $Restrictions.

    SPICELIB Version 1.0.1, 08-OCT-2009 (NJB)

        Updated header.

    SPICELIB Version 1.0.0, 09-JUN-1996 (WLT)
Fri Dec 31 18:36:27 2021