/
cpBody.R
268 lines (241 loc) · 7.75 KB
/
cpBody.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# Auto-generated
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Allocate and initialize a cpBody.
#'
#' Allocate and initialize a cpBody.
#'
#' C function prototype: \code{CP_EXPORT cpBody* cpBodyNew(cpFloat mass, cpFloat moment);}
#'
#' @param mass [\code{cpFloat}]
#' @param moment [\code{cpFloat}]
#'
#' @return [\code{cpBody *}]
#'
#' @export
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cpBodyNew <- function(mass, moment) {
.Call("cpBodyNew_", mass, moment)
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Set the position of a body.
#'
#' Set the position of a body.
#'
#' C function prototype: \code{CP_EXPORT cpVect cpBodyGetPosition(const cpBody *body);}
#'
#' @param body [\code{cpBody *}]
#'
#' @return [\code{cpVect *}]
#'
#' @export
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cpBodyGetPosition <- function(body) {
stopifnot(inherits(body, "cpBody"))
.Call("cpBodyGetPosition_", body)
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Set the position of the body.
#'
#' Set the position of the body.
#'
#' C function prototype: \code{CP_EXPORT void cpBodySetPosition(cpBody *body, cpVect pos);}
#'
#' @param body [\code{cpBody *}]
#' @param pos [\code{cpVect *}]
#'
#' @export
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cpBodySetPosition <- function(body, pos) {
stopifnot(inherits(body, "cpBody"))
stopifnot(inherits(pos, "cpVect"))
.Call("cpBodySetPosition_", body, pos)
invisible(NULL)
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Get the offset of the center of gravity in body local coordinates.
#'
#' Get the offset of the center of gravity in body local coordinates.
#'
#' C function prototype: \code{CP_EXPORT cpVect cpBodyGetCenterOfGravity(const cpBody *body);}
#'
#' @param body [\code{cpBody *}]
#'
#' @return [\code{cpVect *}]
#'
#' @export
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cpBodyGetCenterOfGravity <- function(body) {
stopifnot(inherits(body, "cpBody"))
.Call("cpBodyGetCenterOfGravity_", body)
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Get the velocity of the body.
#'
#' Get the velocity of the body.
#'
#' C function prototype: \code{CP_EXPORT cpVect cpBodyGetVelocity(const cpBody *body);}
#'
#' @param body [\code{cpBody *}]
#'
#' @return [\code{cpVect *}]
#'
#' @export
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cpBodyGetVelocity <- function(body) {
stopifnot(inherits(body, "cpBody"))
.Call("cpBodyGetVelocity_", body)
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Set the velocity of the body.
#'
#' Set the velocity of the body.
#'
#' C function prototype: \code{CP_EXPORT void cpBodySetVelocity(cpBody *body, cpVect velocity);}
#'
#' @param body [\code{cpBody *}]
#' @param velocity [\code{cpVect *}]
#'
#' @export
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cpBodySetVelocity <- function(body, velocity) {
stopifnot(inherits(body, "cpBody"))
stopifnot(inherits(velocity, "cpVect"))
.Call("cpBodySetVelocity_", body, velocity)
invisible(NULL)
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Get the force applied to the body for the next time step.
#'
#' Get the force applied to the body for the next time step.
#'
#' C function prototype: \code{CP_EXPORT cpVect cpBodyGetForce(const cpBody *body);}
#'
#' @param body [\code{cpBody *}]
#'
#' @return [\code{cpVect *}]
#'
#' @export
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cpBodyGetForce <- function(body) {
stopifnot(inherits(body, "cpBody"))
.Call("cpBodyGetForce_", body)
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Get the angle of the body.
#'
#' Get the angle of the body.
#'
#' C function prototype: \code{CP_EXPORT cpFloat cpBodyGetAngle(const cpBody *body);}
#'
#' @param body [\code{cpBody *}]
#'
#' @return [\code{cpFloat}]
#'
#' @export
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cpBodyGetAngle <- function(body) {
stopifnot(inherits(body, "cpBody"))
.Call("cpBodyGetAngle_", body)
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Set the angle of a body.
#'
#' Set the angle of a body.
#'
#' C function prototype: \code{CP_EXPORT void cpBodySetAngle(cpBody *body, cpFloat a);}
#'
#' @param body [\code{cpBody *}]
#' @param a [\code{cpFloat}]
#'
#' @export
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cpBodySetAngle <- function(body, a) {
stopifnot(inherits(body, "cpBody"))
.Call("cpBodySetAngle_", body, a)
invisible(NULL)
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Get the angular velocity of the body.
#'
#' Get the angular velocity of the body.
#'
#' C function prototype: \code{CP_EXPORT cpFloat cpBodyGetAngularVelocity(const cpBody *body);}
#'
#' @param body [\code{cpBody *}]
#'
#' @return [\code{cpFloat}]
#'
#' @export
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cpBodyGetAngularVelocity <- function(body) {
stopifnot(inherits(body, "cpBody"))
.Call("cpBodyGetAngularVelocity_", body)
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Set the angular velocity of the body.
#'
#' Set the angular velocity of the body.
#'
#' C function prototype: \code{CP_EXPORT void cpBodySetAngularVelocity(cpBody *body, cpFloat angularVelocity);}
#'
#' @param body [\code{cpBody *}]
#' @param angularVelocity [\code{cpFloat}]
#'
#' @export
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cpBodySetAngularVelocity <- function(body, angularVelocity) {
stopifnot(inherits(body, "cpBody"))
.Call("cpBodySetAngularVelocity_", body, angularVelocity)
invisible(NULL)
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Get the torque applied to the body for the next time step.
#'
#' Get the torque applied to the body for the next time step.
#'
#' C function prototype: \code{CP_EXPORT cpFloat cpBodyGetTorque(const cpBody *body);}
#'
#' @param body [\code{cpBody *}]
#'
#' @return [\code{cpFloat}]
#'
#' @export
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cpBodyGetTorque <- function(body) {
stopifnot(inherits(body, "cpBody"))
.Call("cpBodyGetTorque_", body)
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Set the torque applied to the body for the next time step.
#'
#' Set the torque applied to the body for the next time step.
#'
#' C function prototype: \code{CP_EXPORT void cpBodySetTorque(cpBody *body, cpFloat torque);}
#'
#' @param body [\code{cpBody *}]
#' @param torque [\code{cpFloat}]
#'
#' @export
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cpBodySetTorque <- function(body, torque) {
stopifnot(inherits(body, "cpBody"))
.Call("cpBodySetTorque_", body, torque)
invisible(NULL)
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Get the rotation vector of the body. (The x basis vector of it's transform.)
#'
#' Get the rotation vector of the body. (The x basis vector of it's transform.)
#'
#' C function prototype: \code{CP_EXPORT cpVect cpBodyGetRotation(const cpBody *body);}
#'
#' @param body [\code{cpBody *}]
#'
#' @return [\code{cpVect *}]
#'
#' @export
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cpBodyGetRotation <- function(body) {
stopifnot(inherits(body, "cpBody"))
.Call("cpBodyGetRotation_", body)
}