BRL-CAD
bn_tri_tri_isect.c
Go to the documentation of this file.
1 /* B N _ T R I _ T R I _ I S E C T . C
2  * BRL-CAD
3  *
4  * Copyright (c) 2011-2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 
21 #include "common.h"
22 
23 #include <stdio.h>
24 
25 #include "bu.h"
26 #include "bn.h"
27 
28 
29 int
30 main(int argc, char **argv)
31 {
32  int expected_result = 0;
33  int actual_result = 0;
34  float f1, f2, f3 = 0.0;
35  point_t V0 = VINIT_ZERO;
36  point_t V1 = VINIT_ZERO;
37  point_t V2 = VINIT_ZERO;
38  point_t U0 = VINIT_ZERO;
39  point_t U1 = VINIT_ZERO;
40  point_t U2 = VINIT_ZERO;
41 
42  if (argc != 8)
43  bu_exit(1, "ERROR: input format is V0x,V0y,V0z V1x,V1y,V1z V2x,V2y,V2z U0x,U0y,U0z U1x,U1y,U1z U2x,U2y,U2z expected_result [%s]\n", argv[0]);
44 
45  sscanf(argv[1], "%f,%f,%f", &f1, &f2, &f3);
46  VSET(V0, f1, f2, f3);
47 
48  sscanf(argv[2], "%f,%f,%f", &f1, &f2, &f3);
49  VSET(V1, f1, f2, f3);
50 
51  sscanf(argv[3], "%f,%f,%f", &f1, &f2, &f3);
52  VSET(V2, f1, f2, f3);
53 
54  sscanf(argv[4], "%f,%f,%f", &f1, &f2, &f3);
55  VSET(U0, f1, f2, f3);
56 
57  sscanf(argv[5], "%f,%f,%f", &f1, &f2, &f3);
58  VSET(U1, f1, f2, f3);
59 
60  sscanf(argv[6], "%f,%f,%f", &f1, &f2, &f3);
61  VSET(U2, f1, f2, f3);
62 
63  sscanf(argv[7], "%d", &expected_result);
64 
65  actual_result = bn_tri_tri_isect(V0, V1, V2, U0, U1, U2);
66 
67  bu_log("result: %d\n", actual_result);
68 
69  if (expected_result == actual_result) {
70  return 0;
71  }
72 
73  return -1;
74 }
75 
76 
77 /** @} */
78 /*
79  * Local Variables:
80  * mode: C
81  * tab-width: 8
82  * indent-tabs-mode: t
83  * c-file-style: "stroustrup"
84  * End:
85  * ex: shiftwidth=4 tabstop=8
86  */
void bu_log(const char *,...) _BU_ATTR_PRINTF12
Definition: log.c:176
#define VSET(a, b, c, d)
Definition: color.c:53
Header file for the BRL-CAD common definitions.
int bn_tri_tri_isect(point_t V0, point_t V1, point_t V2, point_t U0, point_t U1, point_t U2)
Definition: tri_tri.c:319
struct f2 f2
int main(int argc, char **argv)
void bu_exit(int status, const char *fmt,...) _BU_ATTR_NORETURN _BU_ATTR_PRINTF23
Definition: bomb.c:195
struct f1 f1