pcb 4.1.1
An interactive printed circuit board layout editor.

tribox3.c File Reference

#include <math.h>
#include <stdio.h>
Include dependency graph for tribox3.c:

Go to the source code of this file.

Defines

#define X   0
#define Y   1
#define Z   2
#define CROSS(dest, v1, v2)
#define DOT(v1, v2)   (v1[0]*v2[0]+v1[1]*v2[1]+v1[2]*v2[2])
#define SUB(dest, v1, v2)
#define FINDMINMAX(x0, x1, x2, min, max)
#define AXISTEST_X01(a, b, fa, fb)
#define AXISTEST_X2(a, b, fa, fb)
#define AXISTEST_Y02(a, b, fa, fb)
#define AXISTEST_Y1(a, b, fa, fb)
#define AXISTEST_Z12(a, b, fa, fb)
#define AXISTEST_Z0(a, b, fa, fb)

Functions

int planeBoxOverlap (double normal[3], double vert[3], double maxbox[3])
int triBoxOverlap (double boxcenter[3], double boxhalfsize[3], double triverts[3][3])

Define Documentation

#define AXISTEST_X01 (   a,
  b,
  fa,
  fb 
)
Value:
p0 = a*v0[Y] - b*v0[Z];                            \
        p2 = a*v2[Y] - b*v2[Z];                            \
        if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} \
        rad = fa * boxhalfsize[Y] + fb * boxhalfsize[Z];   \
        if(min>rad || max<-rad) return 0;

Definition at line 71 of file tribox3.c.

Referenced by triBoxOverlap().

#define AXISTEST_X2 (   a,
  b,
  fa,
  fb 
)
Value:
p0 = a*v0[Y] - b*v0[Z];                            \
        p1 = a*v1[Y] - b*v1[Z];                            \
        if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} \
        rad = fa * boxhalfsize[Y] + fb * boxhalfsize[Z];   \
        if(min>rad || max<-rad) return 0;

Definition at line 78 of file tribox3.c.

Referenced by triBoxOverlap().

#define AXISTEST_Y02 (   a,
  b,
  fa,
  fb 
)
Value:
p0 = -a*v0[X] + b*v0[Z];                           \
        p2 = -a*v2[X] + b*v2[Z];                           \
        if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} \
        rad = fa * boxhalfsize[X] + fb * boxhalfsize[Z];   \
        if(min>rad || max<-rad) return 0;

Definition at line 86 of file tribox3.c.

Referenced by triBoxOverlap().

#define AXISTEST_Y1 (   a,
  b,
  fa,
  fb 
)
Value:
p0 = -a*v0[X] + b*v0[Z];                           \
        p1 = -a*v1[X] + b*v1[Z];                           \
        if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} \
        rad = fa * boxhalfsize[X] + fb * boxhalfsize[Z];   \
        if(min>rad || max<-rad) return 0;

Definition at line 93 of file tribox3.c.

Referenced by triBoxOverlap().

#define AXISTEST_Z0 (   a,
  b,
  fa,
  fb 
)
Value:
p0 = a*v0[X] - b*v0[Y];                            \
        p1 = a*v1[X] - b*v1[Y];                            \
        if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} \
        rad = fa * boxhalfsize[X] + fb * boxhalfsize[Y];   \
        if(min>rad || max<-rad) return 0;

Definition at line 109 of file tribox3.c.

Referenced by triBoxOverlap().

#define AXISTEST_Z12 (   a,
  b,
  fa,
  fb 
)
Value:
p1 = a*v1[X] - b*v1[Y];                            \
        p2 = a*v2[X] - b*v2[Y];                            \
        if(p2<p1) {min=p2; max=p1;} else {min=p1; max=p2;} \
        rad = fa * boxhalfsize[X] + fb * boxhalfsize[Y];   \
        if(min>rad || max<-rad) return 0;

Definition at line 102 of file tribox3.c.

Referenced by triBoxOverlap().

#define CROSS (   dest,
  v1,
  v2 
)
Value:
dest[0]=v1[1]*v2[2]-v1[2]*v2[1]; \
          dest[1]=v1[2]*v2[0]-v1[0]*v2[2]; \
          dest[2]=v1[0]*v2[1]-v1[1]*v2[0];

Definition at line 26 of file tribox3.c.

Referenced by triBoxOverlap().

#define DOT (   v1,
  v2 
)    (v1[0]*v2[0]+v1[1]*v2[1]+v1[2]*v2[2])

Definition at line 31 of file tribox3.c.

Referenced by planeBoxOverlap().

#define FINDMINMAX (   x0,
  x1,
  x2,
  min,
  max 
)
Value:
min = max = x0;   \
  if(x1<min) min=x1;\
  if(x1>max) max=x1;\
  if(x2<min) min=x2;\
  if(x2>max) max=x2;

Definition at line 38 of file tribox3.c.

Referenced by triBoxOverlap().

#define SUB (   dest,
  v1,
  v2 
)
Value:
dest[0]=v1[0]-v2[0]; \
          dest[1]=v1[1]-v2[1]; \
          dest[2]=v1[2]-v2[2];

Definition at line 33 of file tribox3.c.

Referenced by triBoxOverlap().

#define X   0

History: 2004-10-27 Stephane Popinet: changed float to double

Definition at line 22 of file tribox3.c.

Referenced by planeBoxOverlap(), and triBoxOverlap().

#define Y   1

Definition at line 23 of file tribox3.c.

Referenced by triBoxOverlap().

#define Z   2

Definition at line 24 of file tribox3.c.

Referenced by planeBoxOverlap(), and triBoxOverlap().


Function Documentation

int planeBoxOverlap ( double  normal[3],
double  vert[3],
double  maxbox[3] 
)

Definition at line 45 of file tribox3.c.

References DOT, f, X, and Z.

Referenced by triBoxOverlap().

int triBoxOverlap ( double  boxcenter[3],
double  boxhalfsize[3],
double  triverts[3][3] 
)

Definition at line 116 of file tribox3.c.

References AXISTEST_X01, AXISTEST_X2, AXISTEST_Y02, AXISTEST_Y1, AXISTEST_Z0, AXISTEST_Z12, CROSS, FINDMINMAX, max, min, planeBoxOverlap(), SUB, X, Y, and Z.

Referenced by gts_bbox_overlaps_segment(), and gts_bbox_overlaps_triangle().

Here is the call graph for this function: