BRL-CAD
joint.h
Go to the documentation of this file.
1 /* J O I N T . H
2  * BRL-CAD
3  *
4  * Copyright (c) 2004-2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This program 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 program 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 /** @file libged/joint.h
21  *
22  * Joint and constraint information.
23  *
24  * A joint has to contain all the information to describe how two
25  * segments move in relationship to each other.
26  *
27  * The two segments are defined by the arc given. The upper arc
28  * is the fixed part, the lower part is the "moving" part. The arc
29  * can be completely rooted or a partial description.
30  *
31  * In the simplest case, a joint moves in only one direction (1 degree of
32  * freedom) For rotations, this can be described completely as a
33  * quaternion. For a slider, this can be described completely as a unit
34  * vector.
35  *
36  * For two degrees of freedom, Two quaternions describe rotation one then
37  * rotation two. (Math: The two quaternions can be added "?" to make
38  * a new quaternion that represents the movement around both axis) For
39  * sliders, two unit vectors and a starting point define the plane used.
40  *
41  * For three degrees of freedom, three quaternions or three unit vectors.
42  *
43  * The reason we use the three unit vectors rather than the more usual
44  * normal and closest point, is that we can then use a simple parametric
45  * statement of how to move. It would be best that the two vectors be
46  * at right angles to each other, but that is not required.
47  *
48  * This use of unit vectors allows for non-axis aligned movements, it allows
49  * for non-square and non-cube movement.
50  *
51  * Each degree of freedom contains both an upper and lower bound as well
52  * as the current value of the joint. If upper < lower then this degree
53  * of freedom is not used.
54  */
55 
56 #ifndef LIBGED_JOINT_H
57 #define LIBGED_JOINT_H
58 
59 
60 #ifndef FALSE
61 # define FALSE 0
62 #endif
63 
64 #ifndef TRUE
65 # define TRUE 1
66 #endif
67 
68 /* Check if database pointer is NULL */
69 #define CHECK_DBI_NULL \
70  if (dbip == DBI_NULL) { \
71  Tcl_AppendResult(INTERP, "A database is not open!\n", (char *)NULL); \
72  return TCL_ERROR; \
73  }
74 
75 /* Check if the database is read only, and if so return TCL_ERROR */
76 #define CHECK_READ_ONLY \
77  if (dbip->dbi_read_only) { \
78  Tcl_AppendResult(INTERP, "Sorry, this database is READ-ONLY\n", (char *)NULL); \
79  return TCL_ERROR; \
80  }
81 
82 
83 /* NB: The quaternions should (MUST?) have zero twist! */
84 struct arc {
85  struct bu_list l;
86  int type;
87  char **arc;
88  int arc_last;
89  char **original;
90  int org_last;
91 };
92 
93 
94 #define ARC_UNSET 0x0
95 #define ARC_PATH 0x1
96 #define ARC_ARC 0x2
97 #define ARC_LIST 0x4
98 #define ARC_BOTH 0x8
99 
100 struct rotation {
101  quat_t quat; /* direction of rotation */
102  double lower; /* min value in degrees */
103  double upper; /* max value in degrees */
104  double current; /* what the joint is currently at in degrees */
105  double accepted; /* what was the last accepted value of joint */
106 };
107 
108 
109 struct direct {
110  vect_t unitvec;
111  double lower;
112  double upper;
113  double current;
114  double last;
115  double accepted;
116  int changed;
117 };
118 struct joint {
119  struct bu_list l;
120  int uses;
121  char *name;
122  struct arc path;
123  vect_t location;
124 
125  struct rotation rots[3];
126  struct direct dirs[3];
127 
128  struct animate *anim;
129 };
130 #define MAGIC_JOINT_STRUCT 0x4a4f4900 /* 1246710016 */
131 struct jointH {
132  struct bu_list l;
133  struct joint *p;
134  int arc_loc;
135  int flag;
136 };
137 #define MAGIC_JOINT_HANDLE 0x44330048 /* 1144193096 */
138 /* Constraints
139  *
140  * Standard double linked list stuff.
141  * name of the constraint (not required)
142  * Set of is a linked list of joint HANDLES!
143  */
144 struct hold_point {
145  int type; /* SOLID ID + fixed */
146  /* everything should reduce to a point at run time. */
147  vect_t point;
149 
150  struct arc arc; /* Path to object */
151  struct db_full_path path; /* after processing */
152  int flag;
153 };
154 #define ID_FIXED -1
155 
156 #define HOLD_PT_GOOD 0x1
157 
158 struct j_set_desc {
159  char *joint;
160  struct arc path;
161  struct arc exclude;
162 };
163 struct hold {
164  struct bu_list l;
165  char *name;
166  /* set of joints is defined by joint to grip list of joints */
168  char *joint;
169  struct bu_list j_head;
172  double weight;
173  int priority;
174  int flag;
175  double eval;
176 };
177 #define HOLD_FLAG_TRIED 0x1
178 /*
179  * Objective can be one of:
180  * POINT, LINE, LINE_SEGMENT, PLANE, FACE
181  *
182  * The objective can be defined in terms of:
183  * GRIPs, JOINTs or FIXED POINTs
184  */
185 #define MAGIC_HOLD_STRUCT 0x684f4c63 /* 1750027363 */
186 
187 #define FUNTAB_UNLIMITED -1
188 
189 struct funtab {
190  char *ft_name;
191  char *ft_parms;
192  char *ft_comment;
193  int (*ft_func)();
194  int ft_min;
195  int ft_max;
197 };
198 
199 
200 void vls_col_item(struct bu_vls *str, const char *cp);
201 void vls_col_eol(struct bu_vls *str);
202 
203 #endif /* LIBGED_JOINT_H */
204 
205 /*
206  * Local Variables:
207  * mode: C
208  * tab-width: 8
209  * indent-tabs-mode: t
210  * c-file-style: "stroustrup"
211  * End:
212  * ex: shiftwidth=4 tabstop=8
213  */
Definition: joint.h:118
quat_t quat
Definition: joint.h:101
int arc_loc
Definition: joint.h:134
double upper
Definition: joint.h:103
struct bu_list l
Definition: joint.h:164
int changed
Definition: joint.h:116
int flag
Definition: joint.h:135
int vertex_number
Definition: joint.h:148
Definition: list.h:118
struct arc path
Definition: joint.h:160
int(* ft_func)()
Definition: joint.h:193
struct joint * p
Definition: joint.h:133
double lower
Definition: joint.h:111
double accepted
Definition: joint.h:105
int tcl_converted
Definition: joint.h:196
char * name
Definition: joint.h:165
struct bu_list l
Definition: joint.h:132
double current
Definition: joint.h:113
char * ft_parms
Definition: joint.h:191
int org_last
Definition: joint.h:90
struct direct dirs[3]
Definition: joint.h:126
int flag
Definition: joint.h:174
char * name
Definition: joint.h:121
int flag
Definition: joint.h:152
double last
Definition: joint.h:114
void vls_col_item(struct bu_vls *str, const char *cp)
Definition: columns.c:45
struct hold_point effector
Definition: joint.h:170
Definition: joint.h:84
char ** original
Definition: joint.h:89
int ft_min
Definition: joint.h:194
struct bu_list l
Definition: joint.h:119
int uses
Definition: joint.h:120
Definition: joint.h:189
char * ft_name
Definition: joint.h:190
struct arc path
Definition: joint.h:122
vect_t unitvec
Definition: joint.h:110
int arc_last
Definition: joint.h:88
double accepted
Definition: joint.h:115
int type
Definition: joint.h:145
void vls_col_eol(struct bu_vls *str)
Definition: columns.c:73
double lower
Definition: joint.h:102
int priority
Definition: joint.h:173
struct arc exclude
Definition: joint.h:161
struct bu_list l
Definition: joint.h:85
struct j_set_desc j_set
Definition: joint.h:167
char ** arc
Definition: joint.h:87
struct bu_list j_head
Definition: joint.h:169
struct hold_point objective
Definition: joint.h:171
double eval
Definition: joint.h:175
char * joint
Definition: joint.h:168
struct rotation rots[3]
Definition: joint.h:125
int ft_max
Definition: joint.h:195
struct db_full_path path
Definition: joint.h:151
double weight
Definition: joint.h:172
char * ft_comment
Definition: joint.h:192
vect_t point
Definition: joint.h:147
int type
Definition: joint.h:86
Definition: joint.h:131
double current
Definition: joint.h:104
double upper
Definition: joint.h:112
Definition: vls.h:56
Definition: joint.h:163
struct animate * anim
Definition: joint.h:128
vect_t location
Definition: joint.h:123
char * joint
Definition: joint.h:159
Definition: joint.h:109