1 /* billard.h
2 **
3 **    includefile for code for positioning the balls
4 **    Copyright (C) 2001  Florian Berger
5 **    Email: harpin_floh@yahoo.de, florian.berger@jk.uni-linz.ac.at
6 **
7 **    This program is free software; you can redistribute it and/or modify
8 **    it under the terms of the GNU General Public License Version 2 as
9 **    published by the Free Software Foundation;
10 **
11 **    This program is distributed in the hope that it will be useful,
12 **    but WITHOUT ANY WARRANTY; without even the implied warranty of
13 **    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 **    GNU General Public License for more details.
15 **
16 **    You should have received a copy of the GNU General Public License
17 **    along with this program; if not, write to the Free Software
18 **    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 **
20 */
21 
22 #ifndef BILLARD_H
23 #define BILLARD_H
24 
25 #include <stdlib.h>   /* size_t */
26 #include "options.h"
27 #include "billmove.h"
28 #include <math.h>
29 
30 #define TABLE_W  (options_table_size/2.0)
31 #define TABLE_L  (options_table_size)
32 #define TABLE_H  0.84      /* 84 cm */
33 #define BALL_M      0.17   /* 170 g */
34 #define BALL_D   57.15e-3  /* 57.15 mm */
35 //#define BALL_D   70.00e-3  /* 57.15 mm */
36 //#define HOLE1_R   57.15e-3*1.6  /* 57.15 mm */
37 //#define HOLE2_R   57.15e-3*1.3  /* 57.15 mm */
38 //#define HOLE1_R   BALL_D*0.85  /* 57.15 mm */
39 //#define HOLE2_R   BALL_D*0.85  /* 57.15 mm */
40 #define HOLE1_R   (0.110/2.0)  /* d=110 mm */
41 #define HOLE2_R   (0.115/2.0)  /* d=115 mm */
42 #define QUEUE_L    1.4     /* 1.4 m */
43 #define QUEUE_D1   0.035   /* 3.5cm */
44 #define QUEUE_D2   0.010   /* 1.0cm */
45 //#define HOLE1_W  BALL_D*1.7  /* */
46 //#define HOLE2_W  BALL_D*2.0  /* */
47 //#define BANDE_D   0.03  /* 3cm */
48 #define BANDE_D   0.035  /* 3.5cm to be conform with normed opening of middle pockets */
49 #define BANDE_D2RATIO  0.5  /* (1-0.3)*BANDE_D */
50 #define BANDE_D2 (BANDE_D*(1.0-0.3))  /* (1-0.3)*BANDE_D */
51 #define HOLE1_W  (2.0*HOLE1_R-SQR2*BANDE_D*(1.0-HOLE1_TAN))  /* */
52 #define HOLE2_W  (HOLE2_R*2.0+HOLE2_TAN*BANDE_D*2.0)  /* */
53 #define HOLE1_WH  HOLE1_W/2.0  /* */
54 #define HOLE2_WH  HOLE2_W/2.0  /* */
55 #define FRAME_D  (2.0*HOLE2_R+0.05)   /* d_hole+5cm */
56 #define FRAME_H   0.09   /*  9cm */
57 #define FRAME_H2  0.16   /* 16cm */
58 #define FRAME_DH 0.010           /* +7mm */
59 #define FRAME_PHASE 0.01        /* 1cm */
60 #define FRAME_DW    0.017        /* 1.7cm */
61 #define WOOD_D   (FRAME_D-BANDE_D)  /* */
62 //#define HOLE1_TAN  1.6  /* cotan(35�) */
63 //#define HOLE2_TAN  0.5  /* */
64 #define HOLE1_TAN  1.42815 /* cotan(35�) */
65 #define HOLE2_TAN  0.36397 /* tan(20�) */
66 //#define HOLE1_XYOFFS (HOLE1_R/SQR2)  /* */
67 //#define HOLE2_XYOFFS HOLE2_R  /* */
68 #define HOLE1_XYOFFS (0.04/SQR2)  /* */
69 #define HOLE2_XYOFFS (HOLE2_R+0.005)  /* */
70 #define HOLE1_AIMOFFS 0.02  /* */
71 #define HOLE2_AIMOFFS 0.02  /* */
72 #define HOLE1_PHASE   0.005  /* */
73 #define HOLE2_PHASE   0.005  /* */
74 #define SQR2     sqrt(2.0)
75 #define BALL_FULL 1
76 #define BALL_HALF 2
77 #define BALL_ANY  0
78 
79 #ifndef BILLARD_C
80 extern void (*create_scene)( BallsType * balls );
81 extern void (*create_walls)( BordersType * walls );
82 #endif
83 
84 void create_0hole_walls( BordersType * walls );   /* carambol */
85 void create_6hole_walls( BordersType * walls );   /* pool */
86 
87 void create_8ball_scene   ( BallsType * balls );   /* 8-pool */
88 void create_9ball_scene   ( BallsType * balls );   /* 9-pool */
89 void create_carambol_scene( BallsType * balls );   /* carambol */
90 void create_snooker_scene ( BallsType * balls );   /* snooker */
91 
92 int balls_in_game( BallsType * balls, int full_half );
93 
94 void setfunc_create_scene( void (*func)( BallsType * balls ) );
95 void setfunc_create_walls( void (*func)( BordersType * walls ) );
96 void setfunc_malloc_free( void * (*func_malloc)( size_t size ), void (*func_free)( void * ptr ) );
97 
98 #endif /* BILLARD_H */
99