Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(vector), | intent(in), | DIMENSION(:) | :: | VList | ||
integer, | intent(in) | :: | NSides | |||
type(vector), | intent(inout) | :: | OutNewellSurfaceNormalVector |
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
SUBROUTINE CreateNewellSurfaceNormalVector(VList,NSides,OutNewellSurfaceNormalVector)
! SUBROUTINE INFORMATION:
! AUTHOR Linda Lawrie
! DATE WRITTEN Jan 2011
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
! This subroutine creates a "Newell" surface normal vector from the vector list
! for a surface face.
! METHODOLOGY EMPLOYED:
! na
! REFERENCES:
! September 2010: from OpenGL.org
! Begin Function CalculateSurfaceNormal (Input Polygon) Returns Vector
!
! Set Vertex Normal to (0, 0, 0)
!
! Begin Cycle for Index in [0, Polygon.vertexNumber)
!
! Set Vertex Current to Polygon.verts[Index]
! Set Vertex Next to Polygon.verts[(Index plus 1) mod Polygon.vertexNumber]
!
! Set Normal.x to Sum of Normal.x and (multiply (Current.y minus Next.y) by (Current.z plus Next.z)
! Set Normal.y to Sum of Normal.y and (multiply (Current.z minus Next.z) by (Current.x plus Next.x)
! Set Normal.z to Sum of Normal.z and (multiply (Current.x minus Next.x) by (Current.y plus Next.y)
!
! End Cycle
!
! Returning Normalize(Normal)
!
! End Function
! USE STATEMENTS:
! na
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE ARGUMENT DEFINITIONS:
TYPE (Vector), DIMENSION(:), INTENT(IN) :: VList
INTEGER, INTENT(IN) :: NSides
TYPE (Vector), INTENT(INOUT) :: OutNewellSurfaceNormalVector
! SUBROUTINE PARAMETER DEFINITIONS:
! na
! INTERFACE BLOCK SPECIFICATIONS
! na
! DERIVED TYPE DEFINITIONS
! na
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
! TYPE (Vector) :: U
! TYPE (Vector) :: V
INTEGER Side
INTEGER curVert
INTEGER nextVert
real(r64) :: xvalue
real(r64) :: yvalue
real(r64) :: zvalue
OutNewellSurfaceNormalVector=0.0d0
xvalue=0.0d0
yvalue=0.0d0
zvalue=0.0d0
! IF (NSides > 3) THEN
DO Side=1,NSides
curVert=Side
nextVert=Side+1
if (nextVert > NSides) nextVert=1
xvalue=xvalue+ (VList(curVert)%y-VList(nextVert)%y) * (VList(curVert)%z+VList(nextVert)%z)
yvalue=yvalue+ (VList(curVert)%z-VList(nextVert)%z) * (VList(curVert)%x+VList(nextVert)%x)
zvalue=zvalue+ (VList(curVert)%x-VList(nextVert)%x) * (VList(curVert)%y+VList(nextVert)%y)
ENDDO
! ELSE ! Triangle
! U=VList(2)-VList(1)
! V=VList(3)-VList(1)
! xvalue=(U%y*V%z)-(U%z*V%y)
! yvalue=(U%z*V%x)-(U%x*V%z)
! zvalue=(U%x*V%y)-(U%y*V%x)
! ENDIF
OutNewellSurfaceNormalVector%x=xvalue
OutNewellSurfaceNormalVector%y=yvalue
OutNewellSurfaceNormalVector%z=zvalue
OutNewellSurfaceNormalVector=VecNormalize(OutNewellSurfaceNormalVector)
RETURN
END SUBROUTINE CreateNewellSurfaceNormalVector