Chipmunk2D Pro API Reference  7.0.0
ChipmunkConstraint.h
1 /* Copyright (c) 2013 Scott Lembcke and Howling Moon Software
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining a copy
4  * of this software and associated documentation files (the "Software"), to deal
5  * in the Software without restriction, including without limitation the rights
6  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7  * copies of the Software, and to permit persons to whom the Software is
8  * furnished to do so, subject to the following conditions:
9  *
10  * The above copyright notice and this permission notice shall be included in
11  * all copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19  * SOFTWARE.
20  */
21 
33 @interface ChipmunkConstraint : NSObject <ChipmunkBaseObject> {
34 @private
35  id _userData;
36 }
37 
39 @property(nonatomic, readonly) cpConstraint *constraint;
40 
42 @property(nonatomic, readonly) ChipmunkBody *bodyA;
43 
45 @property(nonatomic, readonly) ChipmunkBody *bodyB;
46 
49 +(ChipmunkConstraint *)constraintFromCPConstraint:(cpConstraint *)constraint;
50 
56 @property(nonatomic, assign) cpFloat maxForce;
57 
62 @property(nonatomic, assign) cpFloat errorBias;
63 
68 @property(nonatomic, assign) cpFloat maxBias;
69 
75 @property(nonatomic, assign) BOOL collideBodies;
76 
78 @property(nonatomic, readonly) cpFloat impulse;
79 
81 @property(nonatomic, readonly) ChipmunkSpace *space;
82 
87 @property(nonatomic, assign) id userData;
88 
90 -(void)preSolve:(ChipmunkSpace *)space;
91 
94 -(void)postSolve:(ChipmunkSpace *)space;
95 
96 @end
97 
98 
104 
109 + (ChipmunkPinJoint *)pinJointWithBodyA:(ChipmunkBody *)a bodyB:(ChipmunkBody *)b anchorA:(cpVect)anchorA anchorB:(cpVect)anchorB;
110 
115 - (id)initWithBodyA:(ChipmunkBody *)a bodyB:(ChipmunkBody *)b anchorA:(cpVect)anchorA anchorB:(cpVect)anchorB;
116 
118 @property(nonatomic, assign) cpVect anchorA;
119 
121 @property(nonatomic, assign) cpVect anchorB;
122 
124 @property(nonatomic, assign) cpFloat dist;
125 
126 @end
127 
128 
134 
138 + (ChipmunkSlideJoint *)slideJointWithBodyA:(ChipmunkBody *)a bodyB:(ChipmunkBody *)b anchorA:(cpVect)anchorA anchorB:(cpVect)anchorB min:(cpFloat)min max:(cpFloat)max;
139 
143 - (id)initWithBodyA:(ChipmunkBody *)a bodyB:(ChipmunkBody *)b anchorA:(cpVect)anchorA anchorB:(cpVect)anchorB min:(cpFloat)min max:(cpFloat)max;
144 
146 @property(nonatomic, assign) cpVect anchorA;
147 
149 @property(nonatomic, assign) cpVect anchorB;
150 
152 @property(nonatomic, assign) cpFloat min;
153 
155 @property(nonatomic, assign) cpFloat max;
156 
157 @end
158 
159 
164 
169 + (ChipmunkPivotJoint *)pivotJointWithBodyA:(ChipmunkBody *)a bodyB:(ChipmunkBody *)b anchorA:(cpVect)anchorA anchorB:(cpVect)anchorB;
170 
174 + (ChipmunkPivotJoint *)pivotJointWithBodyA:(ChipmunkBody *)a bodyB:(ChipmunkBody *)b pivot:(cpVect)pivot;
175 
180 - (id)initWithBodyA:(ChipmunkBody *)a bodyB:(ChipmunkBody *)b anchorA:(cpVect)anchorA anchorB:(cpVect)anchorB;
181 
185 - (id)initWithBodyA:(ChipmunkBody *)a bodyB:(ChipmunkBody *)b pivot:(cpVect)pivot;
186 
188 @property(nonatomic, assign) cpVect anchorA;
189 
191 @property(nonatomic, assign) cpVect anchorB;
192 
193 @end
194 
195 
200 
208 + (ChipmunkGrooveJoint *)grooveJointWithBodyA:(ChipmunkBody *)a bodyB:(ChipmunkBody *)b grooveA:(cpVect)grooveA grooveB:(cpVect)grooveB anchorB:(cpVect)anchorB;
209 
217 - (id)initWithBodyA:(ChipmunkBody *)a bodyB:(ChipmunkBody *)b grooveA:(cpVect)grooveA grooveB:(cpVect)grooveB anchorB:(cpVect)anchorB;
218 
220 @property(nonatomic, assign) cpVect grooveA;
222 @property(nonatomic, assign) cpVect grooveB;
223 
225 @property(nonatomic, assign) cpVect anchorB;
226 
227 @end
228 
229 
235 
242 + (ChipmunkDampedSpring *)dampedSpringWithBodyA:(ChipmunkBody *)a bodyB:(ChipmunkBody *)b anchorA:(cpVect)anchorA anchorB:(cpVect)anchorB restLength:(cpFloat)restLength stiffness:(cpFloat)stiffness damping:(cpFloat)damping;
243 
250 - (id)initWithBodyA:(ChipmunkBody *)a bodyB:(ChipmunkBody *)b anchorA:(cpVect)anchorA anchorB:(cpVect)anchorB restLength:(cpFloat)restLength stiffness:(cpFloat)stiffness damping:(cpFloat)damping;
251 
253 @property(nonatomic, assign) cpVect anchorA;
254 
256 @property(nonatomic, assign) cpVect anchorB;
257 
259 @property(nonatomic, assign) cpFloat restLength;
260 
262 @property(nonatomic, assign) cpFloat stiffness;
263 
265 @property(nonatomic, assign) cpFloat damping;
266 
267 @end
268 
269 
274 
275 
282 + (ChipmunkDampedRotarySpring *)dampedRotarySpringWithBodyA:(ChipmunkBody *)a bodyB:(ChipmunkBody *)b restAngle:(cpFloat)restAngle stiffness:(cpFloat)stiffness damping:(cpFloat)damping;
283 
290 - (id)initWithBodyA:(ChipmunkBody *)a bodyB:(ChipmunkBody *)b restAngle:(cpFloat)restAngle stiffness:(cpFloat)stiffness damping:(cpFloat)damping;
291 
293 @property(nonatomic, assign) cpFloat restAngle;
294 
296 @property(nonatomic, assign) cpFloat stiffness;
297 
299 @property(nonatomic, assign) cpFloat damping;
300 
301 @end
302 
303 
309 
314 + (ChipmunkRotaryLimitJoint *)rotaryLimitJointWithBodyA:(ChipmunkBody *)a bodyB:(ChipmunkBody *)b min:(cpFloat)min max:(cpFloat)max;
315 
320 - (id)initWithBodyA:(ChipmunkBody *)a bodyB:(ChipmunkBody *)b min:(cpFloat)min max:(cpFloat)max;
321 
323 @property(nonatomic, assign) cpFloat min;
324 
326 @property(nonatomic, assign) cpFloat max;
327 
328 @end
329 
330 
336 
338 + (ChipmunkSimpleMotor *)simpleMotorWithBodyA:(ChipmunkBody *)a bodyB:(ChipmunkBody *)b rate:(cpFloat)rate;
339 
341 - (id)initWithBodyA:(ChipmunkBody *)a bodyB:(ChipmunkBody *)b rate:(cpFloat)rate;
342 
344 @property(nonatomic, assign) cpFloat rate;
345 
346 @end
347 
348 
355 
361 + (ChipmunkGearJoint *)gearJointWithBodyA:(ChipmunkBody *)a bodyB:(ChipmunkBody *)b phase:(cpFloat)phase ratio:(cpFloat)ratio;
362 
368 - (id)initWithBodyA:(ChipmunkBody *)a bodyB:(ChipmunkBody *)b phase:(cpFloat)phase ratio:(cpFloat)ratio;
369 
371 @property(nonatomic, assign) cpFloat phase;
373 @property(nonatomic, assign) cpFloat ratio;
374 
375 @end
376 
381 
387 + (ChipmunkRatchetJoint *)ratchetJointWithBodyA:(ChipmunkBody *)a bodyB:(ChipmunkBody *)b phase:(cpFloat)phase ratchet:(cpFloat)ratchet;
388 
394 - (id)initWithBodyA:(ChipmunkBody *)a bodyB:(ChipmunkBody *)b phase:(cpFloat)phase ratchet:(cpFloat)ratchet;
395 
397 @property(nonatomic, assign) cpFloat angle;
398 
400 @property(nonatomic, assign) cpFloat phase;
401 
403 @property(nonatomic, assign) cpFloat ratchet;
404 
405 @end
ChipmunkBody * bodyB
The second ChipmunkBody the constraint controls.
Definition: ChipmunkConstraint.h:45
id userData
An object that this constraint is associated with.
Definition: ChipmunkConstraint.h:87
cpFloat phase
The angular offset in radians.
Definition: ChipmunkConstraint.h:371
cpFloat impulse
Get the most recent impulse applied by this constraint.
Definition: ChipmunkConstraint.h:78
cpFloat maxBias
Maximum rate (speed) that a joint can be corrected at (defaults to infinity).
Definition: ChipmunkConstraint.h:68
cpFloat ratchet
The angle in radians of each ratchet position. Negative values cause the ratchet to operate in the op...
Definition: ChipmunkConstraint.h:403
cpFloat rate
The relative rotation speed of the two bodies in radians per second.
Definition: ChipmunkConstraint.h:344
cpFloat min
The minimum allowed distance between anchor points.
Definition: ChipmunkConstraint.h:152
Rigid bodies are the basic unit of simulation in Chipmunk.
Definition: ChipmunkBody.h:29
Constrains the angle between two bodies.
Definition: ChipmunkConstraint.h:308
cpFloat stiffness
The young&#39;s modulus of the spring.
Definition: ChipmunkConstraint.h:296
cpFloat stiffness
The young&#39;s modulus of the spring.
Definition: ChipmunkConstraint.h:262
BOOL collideBodies
Whether or not the connected bodies should checked for collisions.
Definition: ChipmunkConstraint.h:75
ChipmunkSpace * space
Get the space the body is added to.
Definition: ChipmunkConstraint.h:81
double cpFloat
Chipmunk&#39;s floating point type.
Definition: chipmunk_types.h:83
Chipmunk spaces are simulation containers.
Definition: ChipmunkSpace.h:32
Ratchet joints create rotary ratches similar to a socket wrench.
Definition: ChipmunkConstraint.h:380
cpFloat damping
The amount of viscous damping to apply.
Definition: ChipmunkConstraint.h:299
cpFloat dist
The distance between the two anchor points that the joint keeps.
Definition: ChipmunkConstraint.h:124
cpFloat phase
The angular offset of the ratchet positions in radians.
Definition: ChipmunkConstraint.h:400
cpConstraint * constraint
Returns a pointer to the underlying cpConstraint C struct.
Definition: ChipmunkConstraint.h:39
Pin joints hold a set distance between points on two bodies.
Definition: ChipmunkConstraint.h:103
Definition: chipmunk_types.h:271
Gear joints constrain the rotational speed of one body to another.
Definition: ChipmunkConstraint.h:354
cpFloat maxForce
Maximum force this constraint is allowed to use (defalts to infinity).
Definition: ChipmunkConstraint.h:56
A spring with a damper.
Definition: ChipmunkConstraint.h:234
cpFloat errorBias
The rate at which joint error is corrected.
Definition: ChipmunkConstraint.h:62
Pivot joints hold two points on two bodies together allowing them to rotate freely around the pivot...
Definition: ChipmunkConstraint.h:163
cpFloat restLength
The length the spring wants to contract or expand to.
Definition: ChipmunkConstraint.h:259
Definition: chipmunk_private.h:385
cpFloat max
The maximum angular delta of the joint in radians.
Definition: ChipmunkConstraint.h:326
Constraints connect two ChipmunkBody objects together.
Definition: ChipmunkConstraint.h:33
cpFloat max
The maximum allowed distance between anchor points.
Definition: ChipmunkConstraint.h:155
cpFloat ratio
The ratio of the rotational speeds.
Definition: ChipmunkConstraint.h:373
Like a ChipmunkDampedSpring, but operates in a rotational fashion.
Definition: ChipmunkConstraint.h:273
cpFloat damping
The amount of viscous damping to apply.
Definition: ChipmunkConstraint.h:265
cpFloat restAngle
The angular offset the spring attempts to keep between the two bodies.
Definition: ChipmunkConstraint.h:293
Groove joints hold a pivot point on one body to line along a line segment on another like a pin in a ...
Definition: ChipmunkConstraint.h:199
ChipmunkBody * bodyA
The first ChipmunkBody the constraint controls.
Definition: ChipmunkConstraint.h:42
Slide joints hold the distance between points on two bodies between a minimum and a maximum...
Definition: ChipmunkConstraint.h:133
Simple motors make two objects spin relative to each other.
Definition: ChipmunkConstraint.h:335
cpFloat angle
The current ratchet position in radians.
Definition: ChipmunkConstraint.h:397
cpFloat min
The minimum angular delta of the joint in radians.
Definition: ChipmunkConstraint.h:323