LCOV - code coverage report
Current view: top level - Core - OOTriangle.h (source / functions) Hit Total Coverage
Test: coverxygen.info Lines: 0 1 0.0 %
Date: 2025-05-28 07:50:54 Functions: 0 0 -

          Line data    Source code
       1           0 : /*
       2             : 
       3             : OOTriangle.h
       4             : 
       5             : Mathematical framework for Oolite.
       6             : 
       7             : Oolite
       8             : Copyright (C) 2004-2013 Giles C Williams and contributors
       9             : 
      10             : This program is free software; you can redistribute it and/or
      11             : modify it under the terms of the GNU General Public License
      12             : as published by the Free Software Foundation; either version 2
      13             : of the License, or (at your option) any later version.
      14             : 
      15             : This program is distributed in the hope that it will be useful,
      16             : but WITHOUT ANY WARRANTY; without even the implied warranty of
      17             : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      18             : GNU General Public License for more details.
      19             : 
      20             : You should have received a copy of the GNU General Public License
      21             : along with this program; if not, write to the Free Software
      22             : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
      23             : MA 02110-1301, USA.
      24             : 
      25             : */
      26             : 
      27             : 
      28             : #ifndef INCLUDED_OOMATHS_h
      29             :         #error Do not include OOTriangle.h directly; include OOMaths.h.
      30             : #else
      31             : 
      32             : 
      33             : typedef struct
      34             : {
      35             :         Vector          v[3];
      36             : } Triangle;
      37             : 
      38             : 
      39             : /* Calculate normal for triangle. */
      40             : OOINLINE Vector calculateNormalForTriangle(Triangle *ioTriangle) NONNULL_FUNC;
      41             : 
      42             : /* Generate a triangle from three vertices. */
      43             : OOINLINE Triangle make_triangle(Vector v0, Vector v1, Vector v2) CONST_FUNC;
      44             : 
      45             : /* resolve vector in arbitrary ijk vectors */
      46             : OOINLINE Vector resolveVectorInIJK(Vector v0, Triangle ijk);
      47             : 
      48             : /* Test whether triangle's area is 0. */
      49             : OOINLINE bool OOTriangleIsDegenerate(Triangle tri) CONST_FUNC;
      50             : 
      51             : 
      52             : /*** Only inline definitions beyond this point ***/
      53             : 
      54             : OOINLINE Triangle make_triangle(Vector v0, Vector v1, Vector v2)
      55             : {
      56             :         return (Triangle){{ v0, v1, v2 }};
      57             : }
      58             : 
      59             : 
      60             : OOINLINE Vector calculateNormalForTriangle(Triangle *tri)
      61             : {
      62             :         Vector v01 = vector_subtract(tri->v[1], tri->v[0]);
      63             :         Vector v12 = vector_subtract(tri->v[2], tri->v[1]);
      64             :         return cross_product(v01, v12);
      65             : }
      66             : 
      67             : 
      68             : OOINLINE Vector resolveVectorInIJK(Vector v0, Triangle ijk)
      69             : {
      70             :         Vector result;
      71             :         result.x = dot_product(v0, ijk.v[0]);
      72             :         result.y = dot_product(v0, ijk.v[1]);
      73             :         result.z = dot_product(v0, ijk.v[2]);
      74             :         return result;
      75             : }
      76             : 
      77             : 
      78             : OOINLINE bool OOTriangleIsDegenerate(Triangle tri)
      79             : {
      80             :         return vector_equal(tri.v[0], tri.v[1]) ||
      81             :                vector_equal(tri.v[1], tri.v[2]) ||
      82             :                vector_equal(tri.v[2], tri.v[0]);
      83             : }
      84             : 
      85             : 
      86             : #endif  /* INCLUDED_OOMATHS_h */

Generated by: LCOV version 1.14