view org/cone-joints.txt @ 121:05e60a0ed043

preliminary eyes are fully implemented
author Robert McIntyre <rlm@mit.edu>
date Sat, 21 Jan 2012 09:55:59 -0700
parents 14b604e955ed
children
line wrap: on
line source




5 (ConeJoint
6 RigidBody A
7 RigidBody B
8 Vector3f PivotA
9 Vector3f PivotB
10 Matrix3f RotA
11 Matrix3f RotB
12 )
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 COORDINATES
22 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 coordinate
25 system. In other words, the origin of the object coincides with the
26 origin of the world, and the XYZ axes of the object coincide with the
27 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 righthandedly
34 about the Z axis, its own X axis will move to coincide with the
35 world's Y axis; its own Y axis will move to coincide with the
36 world's -X axis; its Z axis will remain aligned with the world's
37 Z-axis.
40 In such a way, you can see the way in which the translations and rotations of an
41 object alter its local coordinates.
44 ## a haphazard elaboration of the above
46 Converting from world coordinates to local coordinates amounts to
47 finding the transformation that undoes all the rotations and
48 translations that the Object has suffered, then applying that
49 undoing-transformation to the world coordinates.
51 +position of obj +rot of obj
52 world axes ---------------> x -----------> obj axes
55 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 the
57 Object is at the origin (though still has its rotation, if any) and
58 the test-object is somewhere else (irrelevant).
59 3. Rotate the whole world about the origin so that the Object becomes
60 unrotated. Now the object is unrotated at the origin, and the
61 test-object is somewhere else.
62 4. That somewhere-else is the coordinates of the test-object as seen
63 from the Object's own coordinate system (the system in which the Object is always
64 unrotated and centered at the origin)
66 cf: get-subjective-rotation
67 cf: get-subjective-position
69 ***
72 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
74 Now, to understand the ConeJoint constructor:
75 Suppose you have the position of the cone joint picked out, as well as its
76 orientation (orientation aka rotation matters because the limits of
77 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 "by
79 default, the x-axis").
81 Then:
82 Pivot-a is the position of the joint, as expressed in the coordinate
83 system of object-a.
84 Pivot-a is the position of the joint again, this time as expressed in
85 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 the
91 coordinate system of object-a. By default, it is aligned with a's
92 coordinate system, making the cone's axis along a's x-axis, and its
93 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 by
98 moving the objects. I think the engine prefers to keep object b still
99 and move everything else, but it may not always be so.
101 If inconsistent rotations are given ... I don't know what
102 happens. Beez happens.
105 Modulo a bunch of forced object migration because your pivots give
106 inconsistent indicators of where the joint should be expected, etc., this is
107 how the method works.
111 # Another implementation option would have been to specify the positions and
112 # rotations of THREE things --- object A, object B, and the joint --- all in terms of world
113 # coordinates. This wouldn't be any more or less fragile (i.e. subject to explosions
114 # of inconsistency) but it might be nice to avoid those
115 # transformations into local coordinates, even if we had to introduce
116 # more parameters into such a new method
117 # (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 the
120 # joint in the existing method? Lest it explode in inconsistency? I
121 # suggest we create a clojure method that creates cone joints in the
122 # transformation-free way.
123 # cf. joint-create, my first attempt