1 /*************************************************************************
3 * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
4 * All rights reserved. Email: russ@q12.org Web: www.q12.org *
6 * This library is free software; you can redistribute it and/or *
7 * modify it under the terms of EITHER: *
8 * (1) The GNU Lesser General Public License as published by the Free *
9 * Software Foundation; either version 2.1 of the License, or (at *
10 * your option) any later version. The text of the GNU Lesser *
11 * General Public License is included with this library in the *
13 * (2) The BSD-style license that is included with this library in *
14 * the file LICENSE-BSD.TXT. *
16 * This library is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
19 * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
21 *************************************************************************/
26 #include "joint_internal.h"
30 //****************************************************************************
33 This code is part of the Plane2D ODE joint
35 Wed Apr 23 18:53:43 CEST 2003
39 # define VoXYZ(v1, o1, x, y, z) \
46 static const dReal Midentity
[3][3] =
54 dxJointPlane2D::dxJointPlane2D( dxWorld
*w
) :
57 motor_x
.init( world
);
58 motor_y
.init( world
);
59 motor_angle
.init( world
);
64 dxJointPlane2D::getSureMaxInfo( SureMaxInfo
* info
)
71 dxJointPlane2D::getInfo1( dxJoint::Info1
*info
)
76 if ( motor_x
.fmax
> 0 )
77 row_motor_x
= info
->m
++;
78 if ( motor_y
.fmax
> 0 )
79 row_motor_y
= info
->m
++;
80 if ( motor_angle
.fmax
> 0 )
81 row_motor_angle
= info
->m
++;
87 dxJointPlane2D::getInfo2( dxJoint::Info2
*info
)
92 dReal eps
= info
->fps
* info
->erp
;
96 (v2, omega2 not important (== static environment))
103 <=> ( 0 0 1 ) (vx) ( 0 0 0 ) (wx) ( 0 )
104 ( 0 0 0 ) (vy) + ( 1 0 0 ) (wy) = ( 0 )
105 ( 0 0 0 ) (vz) ( 0 1 0 ) (wz) ( 0 )
109 // fill in linear and angular coeff. for left hand side:
111 VoXYZ( &info
->J1l
[r0
], = , 0, 0, 1 );
112 VoXYZ( &info
->J1l
[r1
], = , 0, 0, 0 );
113 VoXYZ( &info
->J1l
[r2
], = , 0, 0, 0 );
115 VoXYZ( &info
->J1a
[r0
], = , 0, 0, 0 );
116 VoXYZ( &info
->J1a
[r1
], = , 1, 0, 0 );
117 VoXYZ( &info
->J1a
[r2
], = , 0, 1, 0 );
119 // error correction (against drift):
121 // a) linear vz, so that z (== pos[2]) == 0
122 info
->c
[0] = eps
* -node
[0].body
->posr
.pos
[2];
125 // b) angular correction? -> left to application !!!
126 dReal
*body_z_axis
= &node
[0].body
->R
[8];
127 info
->c
[1] = eps
* + atan2( body_z_axis
[1], body_z_axis
[2] ); // wx error
128 info
->c
[2] = eps
* -atan2( body_z_axis
[0], body_z_axis
[2] ); // wy error
131 // if the slider is powered, or has joint limits, add in the extra row:
133 if ( row_motor_x
> 0 )
134 motor_x
.addLimot( this, info
, row_motor_x
, Midentity
[0], 0 );
136 if ( row_motor_y
> 0 )
137 motor_y
.addLimot( this, info
, row_motor_y
, Midentity
[1], 0 );
139 if ( row_motor_angle
> 0 )
140 motor_angle
.addLimot( this, info
, row_motor_angle
, Midentity
[2], 1 );
145 dxJointPlane2D::type() const
147 return dJointTypePlane2D
;
152 dxJointPlane2D::size() const
154 return sizeof( *this );
159 void dJointSetPlane2DXParam( dxJoint
*joint
,
160 int parameter
, dReal value
)
162 dUASSERT( joint
, "bad joint argument" );
163 checktype( joint
, Plane2D
);
164 dxJointPlane2D
* joint2d
= ( dxJointPlane2D
* )( joint
);
165 joint2d
->motor_x
.set( parameter
, value
);
169 void dJointSetPlane2DYParam( dxJoint
*joint
,
170 int parameter
, dReal value
)
172 dUASSERT( joint
, "bad joint argument" );
173 checktype( joint
, Plane2D
);
174 dxJointPlane2D
* joint2d
= ( dxJointPlane2D
* )( joint
);
175 joint2d
->motor_y
.set( parameter
, value
);
180 void dJointSetPlane2DAngleParam( dxJoint
*joint
,
181 int parameter
, dReal value
)
183 dUASSERT( joint
, "bad joint argument" );
184 checktype( joint
, Plane2D
);
185 dxJointPlane2D
* joint2d
= ( dxJointPlane2D
* )( joint
);
186 joint2d
->motor_angle
.set( parameter
, value
);