github.com/archlabjp/eeslism-go@v0.0.0-20231109122333-4bb7bfcdf292/eeslism/PRA.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=PRA.c
    20                Create Date=1998.8.15
    21  
    22  */
    23  
    24  package eeslism
    25  
    26  import (
    27  	"fmt"
    28  	"math"
    29  	"os"
    30  )
    31  
    32  func PRA(U *float64, ls, ms, ns, x, y, z float64) {
    33  	epsilon := 1.0e-6
    34  
    35  	if math.Abs(ls) > epsilon {
    36  		*U = x / ls
    37  	} else if math.Abs(ms) > epsilon {
    38  		*U = y / ms
    39  	} else if math.Abs(ns) > epsilon {
    40  		*U = z / ns
    41  	} else {
    42  		fmt.Printf("ls=%f ms=%f ns=%f\n", ls, ms, ns)
    43  		fmt.Println("errorPRA")
    44  		os.Exit(1)
    45  	}
    46  }