Mercurial > cortex
view org/cone-joints.txt @ 136:47a4d74761f0
fixed some more problems with proprioception
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Wed, 01 Feb 2012 17:39:23 -0700 |
parents | 14b604e955ed |
children |
line wrap: on
line source
5 (ConeJoint6 RigidBody A7 RigidBody B8 Vector3f PivotA9 Vector3f PivotB10 Matrix3f RotA11 Matrix3f RotB12 )14 Parameters:16 The specification of a cone joint depends on local coordinates,17 that is coordinates relative to the given rigid bodies.19 ***20 DIGRESSION ABOUT LOCAL COORDINATES22 Each rigid body has its own coordinate system.23 If an object is placed, unrotated, at the origin of the world,24 then its coordinate system is the same as the world's coordinate25 system. In other words, the origin of the object coincides with the26 origin of the world, and the XYZ axes of the object coincide with the27 XYZ axes of the world.29 When you translate the object, its "origin" goes with it.30 The origin of the object is always the center of the object.32 When you rotate the object, its axes go with it.33 For example, if you rotate the object pi/2 radians righthandedly34 about the Z axis, its own X axis will move to coincide with the35 world's Y axis; its own Y axis will move to coincide with the36 world's -X axis; its Z axis will remain aligned with the world's37 Z-axis.40 In such a way, you can see the way in which the translations and rotations of an41 object alter its local coordinates.44 ## a haphazard elaboration of the above46 Converting from world coordinates to local coordinates amounts to47 finding the transformation that undoes all the rotations and48 translations that the Object has suffered, then applying that49 undoing-transformation to the world coordinates.51 +position of obj +rot of obj52 world axes ---------------> x -----------> obj axes55 1. Start with the world coordinates of the Object and a test-object.56 2. Subtract the world coordinates of the Object from each. Now the57 Object is at the origin (though still has its rotation, if any) and58 the test-object is somewhere else (irrelevant).59 3. Rotate the whole world about the origin so that the Object becomes60 unrotated. Now the object is unrotated at the origin, and the61 test-object is somewhere else.62 4. That somewhere-else is the coordinates of the test-object as seen63 from the Object's own coordinate system (the system in which the Object is always64 unrotated and centered at the origin)66 cf: get-subjective-rotation67 cf: get-subjective-position69 ***72 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!74 Now, to understand the ConeJoint constructor:75 Suppose you have the position of the cone joint picked out, as well as its76 orientation (orientation aka rotation matters because the limits of77 rotation are taken with respect to the xy and xz plane of the _joint's_78 coordinate system. This is what the documentation means by "by79 default, the x-axis").81 Then:82 Pivot-a is the position of the joint, as expressed in the coordinate83 system of object-a.84 Pivot-a is the position of the joint again, this time as expressed in85 the coordinate system of object-b.87 (Use get-subjective-position to calculate this conveniently)90 Rot-a is the orientation of the joint, as expressed in the91 coordinate system of object-a. By default, it is aligned with a's92 coordinate system, making the cone's axis along a's x-axis, and its93 limits of rotation in a's xy and xz planes.95 Analogously for b.97 If inconsistent pivot locations are given, it's possible to recover by98 moving the objects. I think the engine prefers to keep object b still99 and move everything else, but it may not always be so.101 If inconsistent rotations are given ... I don't know what102 happens. Beez happens.105 Modulo a bunch of forced object migration because your pivots give106 inconsistent indicators of where the joint should be expected, etc., this is107 how the method works.111 # Another implementation option would have been to specify the positions and112 # rotations of THREE things --- object A, object B, and the joint --- all in terms of world113 # coordinates. This wouldn't be any more or less fragile (i.e. subject to explosions114 # of inconsistency) but it might be nice to avoid those115 # transformations into local coordinates, even if we had to introduce116 # more parameters into such a new method117 # (specifically, the position and orientation of the joint would be new).119 # I wouldn't mind because after all, don't we already need to keep in mind the position and orientation of the120 # joint in the existing method? Lest it explode in inconsistency? I121 # suggest we create a clojure method that creates cone joints in the122 # transformation-free way.123 # cf. joint-create, my first attempt