首页 > 代码 > 行业代码 > 正文

代码

阅读排行

三维向量叉乘函数
2014-02-08 09:50:16   来源:Fcode研讨团队   评论:0 点击:

此函数提供了两个三维向量叉乘的计算方法,符合语法规范,可直接使用

注释里详细介绍了如何使用。
\


subroutine cross_3d ( x1, y1, z1, x2, y2, z2, x3, y3, z3 )
!***************************************************
!! CROSS_3D computes the cross product of two vectors in 3D.
!
!  Definition:
!
!    The cross product in 3D can be regarded as the determinant of the
!    symbolic matrix:
!
!          |  i  j  k |
!      det | x1 y1 z1 |
!          | x2 y2 z2 |
!
!      = ( y1 * z2 - z1 * y2 ) * i
!      + ( z1 * x2 - x1 * z2 ) * j
!      + ( x1 * y2 - y1 * x2 ) * k
!  Modified:
!    19 April 1999
!  Author:
!    John Burkardt
!  Parameters:
!    Input, real X1, Y1, Z1, X2, Y2, Z2, the coordinates of the vectors.
!    Output, real X3, Y3, Z3, the cross product vector. 
  implicit none
  real(8) x1
  real(8) x2
  real(8) x3
  real(8) y1
  real(8) y2
  real(8) y3
  real(8) z1
  real(8) z2
  real(8) z3
  x3 = y1 * z2 - z1 * y2
  y3 = z1 * x2 - x1 * z2
  z3 = x1 * y2 - y1 * x2
end subroutine cross_3d

相关热词搜索:向量叉乘 向量积

上一篇:Fortran 生成正态分布数据
下一篇:Fortran 快速排序算法

分享到: 收藏