声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 2055|回复: 0

[Fortran] 三维向量叉乘函数

[复制链接]
发表于 2015-11-3 17:03 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
此函数提供了两个三维向量叉乘的计算方法,符合语法规范,可直接使用
注释里详细介绍了如何使用。
20140208095527633.jpg
  1. subroutine cross_3d ( x1, y1, z1, x2, y2, z2, x3, y3, z3 )
  2. !***************************************************
  3. !! CROSS_3D computes the cross product of two vectors in 3D.
  4. !
  5. !  Definition:
  6. !
  7. !    The cross product in 3D can be regarded as the determinant of the
  8. !    symbolic matrix:
  9. !
  10. !          |  i  j  k |
  11. !      det | x1 y1 z1 |
  12. !          | x2 y2 z2 |
  13. !
  14. !      = ( y1 * z2 - z1 * y2 ) * i
  15. !      + ( z1 * x2 - x1 * z2 ) * j
  16. !      + ( x1 * y2 - y1 * x2 ) * k
  17. !  Modified:
  18. !    19 April 1999
  19. !  Author:
  20. !    John Burkardt
  21. !  Parameters:
  22. !    Input, real X1, Y1, Z1, X2, Y2, Z2, the coordinates of the vectors.
  23. !    Output, real X3, Y3, Z3, the cross product vector.
  24.   implicit none
  25.   real(8) x1
  26.   real(8) x2
  27.   real(8) x3
  28.   real(8) y1
  29.   real(8) y2
  30.   real(8) y3
  31.   real(8) z1
  32.   real(8) z2
  33.   real(8) z3
  34.   x3 = y1 * z2 - z1 * y2
  35.   y3 = z1 * x2 - x1 * z2
  36.   z3 = x1 * y2 - y1 * x2
  37. end subroutine cross_3d
复制代码
回复
分享到:

使用道具 举报

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-4-19 16:08 , Processed in 0.077698 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表