rsys

Basic data structures and low-level features
git clone git://git.meso-star.fr/rsys.git
Log | Files | Refs | README | LICENSE

real3.h (1229B)


      1 /* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr)
      2  *
      3  * The RSys library is free software: you can redistribute it and/or modify
      4  * it under the terms of the GNU General Public License as published
      5  * by the Free Software Foundation, either version 3 of the License, or
      6  * (at your option) any later version.
      7  *
      8  * The RSys library 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 the RSys library. If not, see <http://www.gnu.org/licenses/>. */
     15 
     16 #ifndef REAL_TYPE__
     17   #error Missing arguments
     18 #endif
     19 
     20 /* Generate common realX funcs */
     21 #define REALX_DIMENSION__ 3
     22 #include "realX_begin.h"
     23 #include "realX.h"
     24 
     25 static FINLINE REAL_TYPE__*
     26 REALX_FUNC__(cross)
     27   (REAL_TYPE__ dst[3],
     28    const REAL_TYPE__ a[3],
     29    const REAL_TYPE__ b[3])
     30 {
     31   REAL_TYPE__ tmp[3];
     32   ASSERT(dst && a && b);
     33   tmp[0] = a[1]*b[2] - a[2]*b[1];
     34   tmp[1] = a[2]*b[0] - a[0]*b[2];
     35   tmp[2] = a[0]*b[1] - a[1]*b[0];
     36   return REALX_FUNC__(set)(dst, tmp);
     37 }
     38 
     39 #include "realX_end.h"