vector_to_angles.c

来自「计算一般形式弹性张量最优化TI近似的C程序 Computing the o」· C语言 代码 · 共 42 行

C
42
字号
/* * Copyright (c) 2005 by the Society of Exploration Geophysicists. * For more information, go to http://software.seg.org/2005/0001 . * You must read and accept usage terms at: * http://software.seg.org/disclaimer.txt before use. * * Revision history: * Original SEG version by Joe Dellinger, BP EPTG, July 2005. */#include <math.h>#include "cmat.h"/* * Express an orientation axis, as given by a unit vector, * in spherical coordinates. * * Input: * 	vec is an input (X,Y,Z) vector. * * Output: * 	phi and theta give the spherical coordinates of the direction * 	it points in, in _DEGREES_. * * phi=0 is the Z axis * phi=90 theta=0 is the X axis * phi=90 theta=90 is the Y axis * * Author Joe Dellinger, Amoco TTC, 19 Feb 1997. */voidvector_to_angles (FLT_DBL vec[3], FLT_DBL * phi, FLT_DBL * theta){    *theta = atan2 (vec[0], vec[1]) / DEGTORAD;    *phi =     atan2 (sqrt (vec[0] * vec[0] + vec[1] * vec[1]), vec[2]) / DEGTORAD;    return;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?