-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhalfspace_normal_triangle_int_3d.f90
More file actions
90 lines (86 loc) · 2.82 KB
/
halfspace_normal_triangle_int_3d.f90
File metadata and controls
90 lines (86 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
subroutine halfspace_normal_triangle_int_3d ( pp, normal, t, int_num, pint )
!*****************************************************************************80
!
!! HALFSPACE_NORMAL_TRIANGLE_INT_3D: intersection ( norm halfspace, triangle ).
!
! Discussion:
!
! The normal form of a halfspace in 3D may be described as the set
! of points P on or "above" a plane described in normal form:
!
! PP is a point on the plane,
! NORMAL is the unit normal vector, pointing "out" of the
! halfspace.
!
! The triangle is specified by listing its three vertices.
!
! The intersection may be described by the number of vertices of the
! triangle that are included in the halfspace, and by the location of
! points between vertices that separate a side of the triangle into
! an included part and an unincluded part.
!
! 0 vertices, 0 separators (no intersection)
! 1 vertex, 0 separators (point intersection)
! 2 vertices, 0 separators (line intersection)
! 3 vertices, 0 separators (triangle intersection)
!
! 1 vertex, 2 separators, (intersection is a triangle)
! 2 vertices, 2 separators, (intersection is a quadrilateral).
!
! Licensing:
!
! This code is distributed under the GNU LGPL license.
!
! Modified:
!
! 06 May 2005
!
! Author:
!
! John Burkardt
!
! Parameters:
!
! Input, double precision PP(3), a point on the bounding plane
! that defines the halfspace.
!
! Input, double precision NORMAL(3), the components of the normal vector
! to the bounding plane that defines the halfspace. By convention, the
! normal vector points "outwards" from the halfspace.
!
! Input, double precision T(3,3), the vertices of the triangle.
!
! Output, integer INT_NUM, the number of intersection points
! returned, which will always be between 0 and 4.
!
! Output, double precision PINT(3,4), the coordinates of the INT_NUM
! intersection points. The points will lie in sequence on the triangle.
! Some points will be vertices, and some may be separators.
!
implicit none
integer, parameter :: dim_num = 3
double precision d
double precision dist1
double precision dist2
double precision dist3
double precision normal(dim_num)
integer int_num
double precision pp(dim_num)
double precision pint(dim_num,4)
double precision t(dim_num,3)
!
! Compute the signed distances between the vertices and the plane.
!
d = - dot_product ( normal(1:dim_num), pp(1:dim_num) )
!
! Compute the signed distances between the vertices and the plane.
!
dist1 = d + dot_product ( normal(1:dim_num), t(1:dim_num,1) )
dist2 = d + dot_product ( normal(1:dim_num), t(1:dim_num,2) )
dist3 = d + dot_product ( normal(1:dim_num), t(1:dim_num,3) )
!
! Now we can find the intersections.
!
call halfspace_triangle_int_3d ( dist1, dist2, dist3, t, int_num, pint )
return
end