CROSS Function

public pure function CROSS(v1, v2) result(cross)

computes the cross product of to 3 dimensional vectors: cross=v1 x v2

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: v1(3)

first input vector

real(kind=wp), intent(in) :: v2(3)

second input vector

Return Value real(kind=wp), (3)

result v1 x v2


Source Code

PURE FUNCTION CROSS(v1,v2)
! MODULES
IMPLICIT NONE
!-----------------------------------------------------------------------------------------------------------------------------------
! INPUT VARIABLES
REAL(wp),INTENT(IN) :: v1(3) !! first input vector
REAL(wp),INTENT(IN) :: v2(3) !! second input vector
!-----------------------------------------------------------------------------------------------------------------------------------
! OUTPUT VARIABLES
REAL(wp)            :: cross(3)  !! result v1 x v2
!-----------------------------------------------------------------------------------------------------------------------------------
! LOCAL VARIABLES
!===================================================================================================================================
cross=(/v1(2)*v2(3)-v1(3)*v2(2),v1(3)*v2(1)-v1(1)*v2(3),v1(1)*v2(2)-v1(2)*v2(1)/)
END FUNCTION CROSS