github.com/archlabjp/eeslism-go@v0.0.0-20231109122333-4bb7bfcdf292/eeslism/YOGEN.go (about)

     1  //This file is part of EESLISM.
     2  //
     3  //Foobar is free software : you can redistribute itand /or modify
     4  //it under the terms of the GNU General Public License as published by
     5  //the Free Software Foundation, either version 3 of the License, or
     6  //(at your option) any later version.
     7  //
     8  //Foobar is distributed in the hope that it will be useful,
     9  //but WITHOUT ANY WARRANTY; without even the implied warranty of
    10  //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
    11  //GNU General Public License for more details.
    12  //
    13  //You should have received a copy of the GNU General Public License
    14  //along with Foobar.If not, see < https://www.gnu.org/licenses/>.
    15  
    16  /*
    17  
    18  	 ベクトルの向き
    19  		 FILE=YOGEN.c
    20  		 Create Date=1999.6.7
    21  	 内積の計算
    22  
    23  */
    24  
    25  package eeslism
    26  
    27  import "math"
    28  
    29  func YOGEN(Qx, Qy, Qz, Px, Py, Pz float64, S *float64, e XYZ) {
    30  	PQx := Px - Qx
    31  	PQy := Py - Qy
    32  	PQz := Pz - Qz
    33  
    34  	CAT(&PQx, &PQy, &PQz) // //20170422 higuchi add
    35  
    36  	PQ := math.Sqrt(PQx*PQx + PQy*PQy + PQz*PQz)
    37  	E := math.Sqrt(e.X*e.X + e.Y*e.Y + e.Z*e.Z)
    38  
    39  	// ↓条件文にした。 20170422 higuchi add
    40  	if PQ == 0.0 {
    41  		*S = -777
    42  	} else {
    43  		*S = (PQx*e.X + PQy*e.Y + PQz*e.Z) / (PQ * E)
    44  	}
    45  }