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