github.com/archlabjp/eeslism-go@v0.0.0-20231109122333-4bb7bfcdf292/eeslism/GRPOINT.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 // GDATA():MP面の中心点を求める 24 // FILE=GRGPOINT.c 25 // Create Date=1999.11.1 26 // 27 //*/ 28 29 func GRGPOINT(mp []P_MENN, mpn int) { 30 const M_rad = math.Pi / 180.0 31 32 for i := 0; i < mpn; i++ { 33 GDATA(&mp[i], &mp[i].G) 34 35 ex := mp[i].P[1].X - mp[i].P[0].X 36 ey := mp[i].P[1].Y - mp[i].P[0].Y 37 ez := mp[i].P[1].Z - mp[i].P[0].Z 38 39 if math.Abs(ez) < 1e-6 { 40 mp[i].grp.X = 0.0 41 mp[i].grp.Y = 0.0 42 mp[i].grp.Z = 0.0 43 continue 44 } else { 45 t := -mp[i].G.Z / ez 46 mp[i].grp.X = t*ex + mp[i].G.X - mp[i].grpx*math.Sin(mp[i].wa*M_rad) 47 mp[i].grp.Y = t*ey + mp[i].G.Y - mp[i].grpx*math.Cos(mp[i].wa*M_rad) 48 mp[i].grp.Z = 0.0 49 } 50 } 51 }