github.com/archlabjp/eeslism-go@v0.0.0-20231109122333-4bb7bfcdf292/eeslism/HOUSEN.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 package eeslism 17 18 import "math" 19 20 ///* 21 // 22 // 法線ベクトルを求める 23 // FILE=HOUSEN.c 24 // Create Date=1998.10.26 25 // Update 2007.10.11 higuchi 26 // 27 //*/ 28 29 func HOUSEN(w int, LP []P_MENN) { 30 for i := 0; i < w; i++ { 31 x := LP[i].P[1].X - LP[i].P[0].X 32 y := LP[i].P[1].Y - LP[i].P[0].Y 33 z := LP[i].P[1].Z - LP[i].P[0].Z 34 x1 := LP[i].P[2].X - LP[i].P[0].X 35 y1 := LP[i].P[2].Y - LP[i].P[0].Y 36 z1 := LP[i].P[2].Z - LP[i].P[0].Z 37 38 LP[i].e.X = y*z1 - z*y1 39 LP[i].e.Y = z*x1 - x*z1 40 LP[i].e.Z = x*y1 - y*x1 41 42 el := math.Sqrt(LP[i].e.X*LP[i].e.X + LP[i].e.Y*LP[i].e.Y + LP[i].e.Z*LP[i].e.Z) 43 LP[i].e.X = LP[i].e.X / el 44 LP[i].e.Y = LP[i].e.Y / el 45 LP[i].e.Z = LP[i].e.Z / el 46 } 47 } 48 49 func HOUSEN2(p0, p1, p2, e *XYZ) { 50 x := p1.X - p0.X 51 y := p1.Y - p0.Y 52 z := p1.Z - p0.Z 53 x1 := p2.X - p0.X 54 y1 := p2.Y - p0.Y 55 z1 := p2.Z - p0.Z 56 57 e.X = y*z1 - z*y1 58 e.Y = z*x1 - x*z1 59 e.Z = x*y1 - y*x1 60 61 el := math.Sqrt(e.X*e.X + e.Y*e.Y + e.Z*e.Z) 62 e.X = e.X / el 63 e.Y = e.Y / el 64 e.Z = e.Z / el 65 }