-
Notifications
You must be signed in to change notification settings - Fork 1
/
PlaneGeometry.f90
62 lines (49 loc) · 1.46 KB
/
PlaneGeometry.f90
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
module PlaneGeomModule
!******************************************************************************
! Peter A. Bosler
! Department of Mathematics
! University of Michigan
!
!******************************************************************************
!
! This module defines functions for performing geometric calculations
! in the plane.
!
use NumberKindsModule
implicit none
public
contains
!----------------
! Basic geometry : length, area, centers of mass, etc.
!----------------
function Distance( xyA, xyB)
real(kreal) :: Distance
real(kreal), intent(in) :: xyA(2), xyB(2)
Distance = sqrt( sum( (xyB - xyA)*(xyB - xyA) ) )
end function
function Midpoint( xyA, xyB )
real(kreal) :: Midpoint(2)
real(kreal), intent(in) :: xyA(2), xyB(2)
Midpoint = 0.5_kreal*(xyA + xyB)
end function
function TriCentroid( xyA, xyB, xyC )
real(kreal) :: TriCentroid(2)
real(kreal), intent(in) :: xyA(2), xyB(2), xyC(2)
TriCentroid = (xyA + xyB + xyC)/3.0_kreal
end function
function QuadCentroid( xyA, xyB, xyC, xyD )
real(kreal) :: QuadCentroid(2)
real(kreal), intent(in) :: xyA(2), xyB(2), xyC(2), xyD(2)
QuadCentroid = 0.25_kreal*(xyA + xyB + xyC + xyD)
end function
function TriArea( xA, xB, xC )
real(kreal) :: TriArea
real(kreal), intent(in) :: xA(2), xB(2), xC(2)
TriArea = 0.5_kreal*abs( -xB(1)*xA(2) + xC(1)*xA(2) + xA(1)*xB(2) - xC(1)*xB(2) - xA(1)*xC(2) + xB(1)*xC(2))
end function
!----------------
! Misc. functions
!----------------
!
end module