9. サポート関数
9.1. 回転関数
Rigid body orientations are represented with quaternions. A quaternion is four numbers [cos( theta /2),sin( theta /2)*u] where theta is a rotation angle and u is a unit length rotation axis.
剛体の方位は四元数で表わされる。シータが回転角度で、uがユニット長 さ回転軸である場合、四元数は[cos(θ/2)およびsin(θ/2)*u]の4つの数である。
剛体の方位は四元数で表わされる。シータが回転角度で、uがユニット長 さ回転軸である場合、四元数は[cos(θ/2)およびsin(θ/2)*u]の4つの数である。
Every rigid body also has a 3x3 rotation matrix that is derived from the quaternion. The rotation matrix and the quaternion always match.
すべての剛体は、さらに四元数から得られる3x3回転マトリックスを 持っている。回転マトリックスおよび四元数は常に一致する。
すべての剛体は、さらに四元数から得られる3x3回転マトリックスを 持っている。回転マトリックスおよび四元数は常に一致する。
Some information about quaternions:
四元数に関するいくつかの情報:
q and -q represent the same rotation.
qと-qは同じ回転を表す。
The inverse of a quaternion is [ q[0] -q[1] -q[2] -q[3] ].
四元数の逆は[q[0]-q[1]-q[2]-q[3]]。
四元数に関するいくつかの情報:
q and -q represent the same rotation.
qと-qは同じ回転を表す。
The inverse of a quaternion is [ q[0] -q[1] -q[2] -q[3] ].
四元数の逆は[q[0]-q[1]-q[2]-q[3]]。
The following are utility functions for dealing with rotation matrices and quaternions.
下記は、回転マトリックスおよび四元数に対処するためのユーティリィ ティ関数である。
下記は、回転マトリックスおよび四元数に対処するためのユーティリィ ティ関数である。
void dRSetIdentity (dMatrix3 R);
Set R to the identity matrix (i.e. no rotation).
単位行列(つまり回転はない)においてRを設定する。
単位行列(つまり回転はない)においてRを設定する。
void dRFromAxisAndAngle (dMatrix3 R, dReal ax, dReal ay, dReal az, dReal angle);
Compute the rotation matrix R as a rotation of angle radians along the axis (ax,ay,az).
軸(ax, ay, az)に沿ったangleラジアンの回転として回転マトリックスRを計算する。
軸(ax, ay, az)に沿ったangleラジアンの回転として回転マトリックスRを計算する。
void dRFromEulerAngles (dMatrix3 R, dReal phi, dReal theta, dReal psi);
Compute the rotation matrix R from the three Euler rotation angles.
void dRFrom2Axes (dMatrix3 R, dReal ax, dReal ay, dReal az, dReal bx, dReal by, dReal bz);
Compute the rotation matrix R from the two vectors `a' (ax,ay,az) and `b' (bx,by,bz). `a' and `b' are the desired x and y axes of the rotated coordinate system. If necessary, `a' and `b' will be made unit length, and `b' will be projected so that it is perpendicular to `a'. The desired z axis is the cross product of `a' and `b'.
void dQSetIdentity (dQuaternion q);
Set q to the identity rotation (i.e. no rotation).
単位行列(つまり回転はない)においてqを設定する。
単位行列(つまり回転はない)においてqを設定する。
void dQFromAxisAndAngle (dQuaternion q, dReal ax, dReal ay, dReal az, dReal angle);
Compute q as a rotation of angle radians along the axis (ax,ay,az).
軸(ax, ay, az)に沿ったangleラジアンの回転として回転マトリックスqを計算する。
軸(ax, ay, az)に沿ったangleラジアンの回転として回転マトリックスqを計算する。
void dQMultiply0 (dQuaternion qa, const dQuaternion qb, const dQuaternion qc); void dQMultiply1 (dQuaternion qa, const dQuaternion qb, const dQuaternion qc); void dQMultiply2 (dQuaternion qa, const dQuaternion qb, const dQuaternion qc); void dQMultiply3 (dQuaternion qa, const dQuaternion qb, const dQuaternion qc);
Set qa = qb*qc. This is that same as qa = rotation qc followed by rotation qb. The 0/1/2 versions are analogous to the multiply functions, i.e. 1 uses the inverse of qb, and 2 uses the inverse of qc. Option 3 uses the inverse of both.
void dQtoR (const dQuaternion q, dMatrix3 R);
Convert quaternion q to rotation matrix R.
四元数qを回転マトリックスRに変換する。
四元数qを回転マトリックスRに変換する。
void dRtoQ (const dMatrix3 R, dQuaternion q);
Convert rotation matrix R to quaternion q.
回転マトリックスRを四元数qに変換する。
回転マトリックスRを四元数qに変換する。
void dWtoDQ (const dVector3 w, const dQuaternion q, dVector4 dq);
Given an existing orientation q and an angular velocity vector w, return in dq the resulting dq/dt.
9.2. 質量(Mass)関数
The mass parameters of a rigid body are described by a dMass structure:
剛体の質量パラメータはdMass構造体で記述される:
剛体の質量パラメータはdMass構造体で記述される:
typedef struct dMass { dReal mass; // 剛体の全体の質量 dVector4 c; // 剛体フレーム(x,y,z)の重心の位置 dMatrix3 I; // PORに関する剛体フレームの3x3慣性テンソル(inertia tensor) } dMass;
The following functions operate on this structure:
下記の関数はこの構造体で動作する:
下記の関数はこの構造体で動作する:
void dMassSetZero (dMass *);
Set all the mass parameters to zero.
全てのmassパラメータをゼロに設定する。
全てのmassパラメータをゼロに設定する。
void dMassSetParameters (dMass *, dReal themass, dReal cgx, dReal cgy, dReal cgz, dReal I11, dReal I22, dReal I33, dReal I12, dReal I13, dReal I23);
Set the mass parameters to the given values. themass is the mass of the body. (cx,cy,cz) is the center of gravity position in the body frame. The Ixx values are the elements of the inertia matrix:
与えられた値について質量パラメータを設定する。themassは剛体 の質量である。(cx,cy,cz)は剛体フレームの重心位置である。Ixx値は慣性マトリックスの要素である:
与えられた値について質量パラメータを設定する。themassは剛体 の質量である。(cx,cy,cz)は剛体フレームの重心位置である。Ixx値は慣性マトリックスの要素である:
[ I11 I12 I13 ] [ I12 I22 I23 ] [ I13 I23 I33 ]
void dMassSetSphere (dMass *, dReal density, dReal radius); void dMassSetSphereTotal (dMass *, dReal total_mass, dReal radius);
Set the mass parameters to represent a sphere of the given radius and density, with the center of mass at (0,0,0) relative to the body. The first function accepts the density of the sphere, the second accepts the total mass of the sphere.
与えられた半径および密度の球体を表すために、剛体の相対的な (0,0,0)の重心で、質量パラメータを設定する。第1の関数は、球体の密度を受理し、第2に球体の質量の合計を受理する。
与えられた半径および密度の球体を表すために、剛体の相対的な (0,0,0)の重心で、質量パラメータを設定する。第1の関数は、球体の密度を受理し、第2に球体の質量の合計を受理する。
void dMassSetCappedCylinder (dMass *, dReal density, int direction, dReal radius, dReal length); void dMassSetCappedCylinderTotal (dMass *, dReal total_mass, int direction, dReal radius, dReal length);
Set the mass parameters to represent a capped cylinder of the given parameters and density, with the center of mass at (0,0,0) relative to the body. The radius of the cylinder (and the spherical cap) is radius. The length of the cylinder (not counting the spherical cap) is length. The cylinder's long axis is oriented along the body's x, y or z axis according to the value of direction (1=x, 2=y, 3=z). The first function accepts the density of the object, the second accepts its total mass.
void dMassSetCylinder (dMass *, dReal density, int direction, dReal radius, dReal length); void dMassSetCylinderTotal (dMass *, dReal total_mass, int direction, dReal radius, dReal length);
Set the mass parameters to represent a flat-ended cylinder of the given parameters and density, with the center of mass at (0,0,0) relative to the body. The radius of the cylinder is radius. The length of the cylinder is length. The cylinder's long axis is oriented along the body's x, y or z axis according to the value of direction (1=x, 2=y, 3=z). The first function accepts the density of the object, the second accepts its total mass.
パラメータと密度が与えられたフラットエンドのシリンダを表すために剛 体の相対的な(0,0,0)の重心で、質量パラメータを設定する。シリンダの半径はradiusである。シリンダの長さはlengthである。シリンダの 長い軸は、剛体のdirection(1=x,2=y,3=z)の値により、x,y,あるいはz軸に沿って適応される。第1の関数は、オブジェクトの密度 を受理する。第2は、その質量の合計を受理する。
パラメータと密度が与えられたフラットエンドのシリンダを表すために剛 体の相対的な(0,0,0)の重心で、質量パラメータを設定する。シリンダの半径はradiusである。シリンダの長さはlengthである。シリンダの 長い軸は、剛体のdirection(1=x,2=y,3=z)の値により、x,y,あるいはz軸に沿って適応される。第1の関数は、オブジェクトの密度 を受理する。第2は、その質量の合計を受理する。
void dMassSetBox (dMass *, dReal density, dReal lx, dReal ly, dReal lz); void dMassSetBoxTotal (dMass *, dReal total_mass, dReal lx, dReal ly, dReal lz);
Set the mass parameters to represent a box of the given dimensions and density, with the center of mass at (0,0,0) relative to the body. The side lengths of the box along the x, y and z axes are lx, ly and lz. The first function accepts the density of the object, the second accepts its total mass.
void dMassAdjust (dMass *, dReal newmass);
Given mass parameters for some object, adjust them so the total mass is now newmass. This is useful when using the above functions to set the mass parameters for certain objects - they take the object density, not the total mass.
オブジェクトに質量パラメータが与えられ、質量の合計が今の newmassであるようにそれらを調節する。オブジェクトのために質量パラメータをセットする上記の機能を使用する場合、これは有用です。それらは質量 の合計ではなく、オブジェクトの密度となる。
オブジェクトに質量パラメータが与えられ、質量の合計が今の newmassであるようにそれらを調節する。オブジェクトのために質量パラメータをセットする上記の機能を使用する場合、これは有用です。それらは質量 の合計ではなく、オブジェクトの密度となる。
void dMassTranslate (dMass *, dReal x, dReal y, dReal z);
Given mass parameters for some object, adjust them to represent the object displaced by (x,y,z) relative to the body frame.
オブジェクトに質量パラメータを与える、剛体フレームの相対的な(x, y,z)に置き換えられたオブジェクトを表わすためにそれらを調整する。
オブジェクトに質量パラメータを与える、剛体フレームの相対的な(x, y,z)に置き換えられたオブジェクトを表わすためにそれらを調整する。
void dMassRotate (dMass *, const dMatrix3 R);
Given mass parameters for some object, adjust them to represent the object rotated by R relative to the body frame.
void dMassAdd (dMass *a, const dMass *b);
Add the mass b to the mass a.
9.3. 数学(Math)関数
[There are quite a lot of these, but they're not standardized enough to document yet].
9.4. エラーとメモリ関数
[Document these later].