\section{�T�v}

\index{Physics}
Physics���W���[���͕����V�~�����[�V�����@�\��񋟂��܂��D
��ɃT�|�[�g����Ă���̂́C�}���`�{�f�B�_�C�i�~�N�X�ƌĂ΂�鍄�̂Ɗ֐߂Ȃǂ̍S������Ȃ铮�͊w�V�~�����[�V�����ł��D
���̂Ƃ���\�t�g�{�f�B�◬�́C�p�[�e�B�N���Ȃǂ̋@�\�̓T�|�[�g����Ă��܂���D

\section{Physics SDK}

\index{PHSdk}
Physics���W���[���̂��ׂẴI�u�W�F�N�g��SDK�N���X\texttt{PHSdk}�ɂ���ĊǗ�����܂��D
\texttt{PHSdk}�N���X�́C�v���O�����̎��s��ʂ��Ă����P�̃I�u�W�F�N�g�����݂���V���O���g���N���X�ł��D
\texttt{PHSdk}�I�u�W�F�N�g���쐬����ɂ͈ȉ��̂悤�ɂ��܂��D
\begin{sourcecode}
PHSdkIf* phSdk = PHSdkIf::CreateSdk();
\end{sourcecode}
�ʏ킱�̑���̓v���O�����̏��������Ɉ�x�������s���܂��D
�܂��CFramework���W���[�����g�p����ꍇ�̓��[�U������\texttt{PHSdk}���쐬����K�v�͂���܂���D

\texttt{PHSdk}�̋@�\�̓V�[���ƌ`��̊Ǘ��ł��D
�V�[���Ɋւ���@�\�͎��߂Ő������܂��D
�܂��C�`��Ɋւ���@�\�͈ȉ��̒ʂ�ł��D

\begin{center}
\begin{tabular}{p{.15\hsize}p{.55\hsize}p{.2\hsize}}
\texttt{PHSdkIf} & &															\\ \midrule
\texttt{CDShapeIf*} & \texttt{CreateShape(const CDShapeDesc\&)}	& �`����쐬	\\
\texttt{CDShapeIf*}	& \texttt{GetShape(int)}					& �`����擾	\\
\texttt{int}		& \texttt{NShape()}							& �`��̐�		\\
\end{tabular}
\end{center}

�قȂ�V�[���ԂŌ`������L�ł���悤�ɁC�`��Ǘ��̓V�[���ł͂Ȃ�\texttt{PHSdk}�̋@�\�ɂȂ��Ă��܂��D
�ڂ�����\ref{chap_collision}�͂��Q�Ƃ��Ă��������D

\section{�V�[��}
\label{sec_physics_scene}

\index{PHScene}
�V�[���͕����V�~�����[�V�������s������\���܂��D
�����̃V�[�����쐬�ł��܂����C�V�[�����m�݂͌��ɓƗ����Ă���C���[�U�����ڋ��n�����������Ȃ�����͉e�����y�ڂ��������Ƃ͂���܂���D
�V�[���N���X��\texttt{PHScene}�ŁC\texttt{PHScene}�I�u�W�F�N�g��\texttt{PHSdk}�ɂ��Ǘ�����܂��D

\begin{center}
\begin{tabular}{p{.15\hsize}p{.55\hsize}p{.2\hsize}}
\multicolumn{3}{l}{\texttt{PHSdkIf}}															\\ \midrule
\texttt{PHSceneIf*}	& \texttt{CreateScene(const PHSceneDesc\& desc)}			& �V�[�����쐬		\\
\texttt{int}		& \texttt{NScene()}											& �V�[���̐�		\\
\texttt{PHSceneIf*}	& \texttt{GetScene(int i)}									& �V�[�����擾		\\
\texttt{void}		& \texttt{MergeScene(PHSceneIf* scene0, PHSceneIf* scene1)}	& �V�[���𓝍�		\\
\end{tabular}
\end{center}

�V�[�����쐬����ɂ͈ȉ��̂悤�ɂ��܂��D
\begin{sourcecode}
PHSceneIf* phScene = phSdk->CreateScene();
\end{sourcecode}
�����Ƀf�B�X�N���v�^���w�肷�邱�Ƃ��ł��܂��D
\texttt{MergeScene}�́C\texttt{scene1}���ۗL����I�u�W�F�N�g�����ׂ�\texttt{scene0}�Ɉړ��������\texttt{scene1}���폜���܂��D

�V�[���͍��̂�֐߂Ȃǂ̗l�X�ȍ\���v�f�̊Ǘ����s���ق��C�����V�~�����[�V�����Ɋւ���ݒ���s���@�\��񋟂��܂��D
�e�\���v�f�̍쐬�ɂ��Ă͂��ꂼ��̐߂Ő������܂��̂ŁC�ȉ��ł̓V�~�����[�V�����ݒ�@�\�ɂ��ďq�ׂ܂��D

\begin{center}
\begin{tabular}{p{.15\hsize}p{.35\hsize}p{.4\hsize}}
\multicolumn{3}{l}{\texttt{PHSceneDesc}}										\\ \midrule
\texttt{double}		&	\texttt{timeStep}	& ���ԃX�e�b�v��					\\
\texttt{unsigned}	&	\texttt{count}		& �V�~�����[�V���������X�e�b�v��	\\
\texttt{Vec3d}		&	\texttt{gravity}	& �d�͉����x						\\
\texttt{double}		&	\texttt{airResistanceRate}	& ��C��R�W��				\\
\texttt{int}		&	\texttt{numIteration}		& LCP�̔�����				\\
\end{tabular}
\end{center}

\begin{center}
\begin{tabular}{p{.15\hsize}p{.55\hsize}p{.2\hsize}}
\multicolumn{3}{l}{\texttt{PHSceneIf}}							  \\ \midrule
\texttt{double}		& \texttt{GetTimeStep()}					& \\
\texttt{void}		& \texttt{SetTimeStep(double)}				& \\
\texttt{unsigned}	& \texttt{GetCount()}						& \\
\texttt{void}		& \texttt{SetCount(unsigned)}				& \\
\texttt{void}		& \texttt{SetGravity(const Vec3d\&)}		& \\
\texttt{Vec3d}		& \texttt{GetGravity()}						& \\
\texttt{void}		& \texttt{SetAirResistanceRate(double)}		& \\
\texttt{double}		& \texttt{GetAirResistanceRate()}			& \\
\texttt{int}		& \texttt{GetNumIteration()}				& \\
\texttt{void}		& \texttt{SetNumIteration()}				& \\
\end{tabular}
\end{center}

\texttt{timeStep}�͈�x�̃V�~�����[�V�����X�e�b�v�Ői�߂鎞�ԕ��ł��D
�������قǃV�~�����[�V�����̐��x�͏オ��܂����C�������ԃV�~�����[�V������i�߂�̂ɂ�����v�Z�R�X�g�͑��債�܂��D

\texttt{count}�̓V�[���쐬��ɃV�~�����[�V���������ݐσX�e�b�v���ł��D
\texttt{count}��\texttt{timeStep}�̐ς��o�ߎ��Ԃ�\���܂��D

\texttt{gravity}�͏d�͉����x�x�N�g���ł��D

\texttt{airResistanceRate}�́C�V�~�����[�V�����̈��萫�����シ�邽�߂ɖ��X�e�b�v�Ɋe���̂̑��x�Ɋ|������W���ł��D
�Ⴆ��\texttt{airRegistanceRate}��$0.95$�ł���΃X�e�b�v���Ƃɑ��x��$95$\%�ɂȂ�܂��D
���̂悤�ɋ����I�Ɍ����������邱�ƂŁC���x���]���Ɉ��萫�𓾂邱�Ƃ��ł��܂��D

\texttt{numIteration}�́C�S���͂��v�Z���邽�߂ɓ����Ŏ��s�����A���S���Y���̔����񐔂ł��D
��ʂɁC�����񐔂Ɋւ��Ďw���֐��I�ɍS���͂̐��x�����サ�C�v�Z�R�X�g�͔��I�ɑ��債�܂��D

\subsection*{�V�~�����[�V�����̎��s}

�V�~�����[�V������$1$�X�e�b�v�i�߂�ɂ�\texttt{Step}�֐����Ăт܂��D

\begin{center}
\begin{tabular}{p{.15\hsize}p{.3\hsize}p{.45\hsize}}
\multicolumn{3}{l}{\texttt{PHSceneIf}}		\\ \midrule
\texttt{void}	& \texttt{Step()}	& �V�~�����[�V������$1$�X�e�b�v�i�߂� \\
\end{tabular}
\end{center}

\texttt{Step}�����s����ƁC�����܂��ɏq�ׂē����Ŏ��̏������s���܂��D
\begin{itemize}
\item �Փ˔���ƐڐG�S���̐���
\item �S���͂̌v�Z
\item ���̂̑��x����шʒu�̍X�V
\end{itemize}

\section{����}

\index{PHSolid}
���͕̂����V�~�����[�V�����̊�{�v�f�ł��D
���̂̃N���X��\texttt{PHSolid}�ł��D
�܂����̂��쐬�E�Ǘ����邽�߂�\texttt{PHScene}�̊֐��������܂��D

\begin{center}
\begin{tabular}{p{.15\hsize}p{.45\hsize}p{.30\hsize}}
\multicolumn{3}{l}{\texttt{PHSceneIf}}									\\ \midrule
\texttt{PHSolidIf*}		& \texttt{CreateSolid(const PHSolidDesc\&)}	& ���̂��쐬���� \\
\texttt{int}			& \texttt{NSolids()}						& ���̂̐� \\
\texttt{PHSolidIf**} 	& \texttt{GetSolids()}						& ���̔z��̐擪�A�h���X \\
\end{tabular}
\end{center}

���̂��쐬����ɂ�
\begin{sourcecode}
PHSolidIf* solid = phScene->CreateSolid();
\end{sourcecode}
�Ƃ��܂��D�f�B�X�N���v�^���w�肵�č쐬���邱�Ƃ��ł��܂��D
�܂��C\texttt{GetSolids}�͍쐬�������̂��i�[���������z��̐擪�A�h���X��Ԃ��܂��D
���������āC�Ⴆ��$0$�Ԗڂ̍��̂��擾����ɂ�
\begin{sourcecode}
PHSolidIf* solid = phScene->GetSolids()[0];      // get 0-th solid
\end{sourcecode}
�Ƃ��܂��D

���ɍ��̎��g�̋@�\��������܂��D

\subsection*{����}

\begin{center}
\begin{tabular}{p{.15\hsize}p{.45\hsize}p{.30\hsize}}
\multicolumn{3}{l}{\texttt{PHSolidDesc}}							\\ \midrule
\texttt{double}		&	\texttt{mass}		& ����					\\
\texttt{Matrix3d}	&	\texttt{inertia}	& �����s��				\\
\texttt{Vec3d}		&	\texttt{center}		& ���ʒ��S				\\
\texttt{bool}		&	\texttt{dynamical}	& �����@���ɂ���������	\\
\end{tabular}
\end{center}

\begin{center}
\begin{tabular}{p{.15\hsize}p{.45\hsize}p{.30\hsize}}
\multicolumn{3}{l}{\texttt{PHSolidIf}}								\\ \midrule
\texttt{double}		& \texttt{GetMass()}						& \\
\texttt{double} 	& \texttt{GetMassInv()}						& \\
\texttt{void} 		& \texttt{SetMass(double)}					& \\
\texttt{Vec3d} 		& \texttt{GetCenterOfMass()}				& \\
\texttt{void} 		& \texttt{SetCenterOfMass(const Vec3d\&)}	& \\
\texttt{Matrix3d} 	& \texttt{GetInertia()}						& \\
\texttt{Matrix3d} 	& \texttt{GetInertiaInv()}					& \\
\texttt{void} 		& \texttt{SetInertia(const Matrix3d\&)}		& \\
\texttt{void} 		& \texttt{CompInertia()}					& \\
\texttt{void} 		& \texttt{SetDynamical(bool)}				& \\
\texttt{bool} 		& \texttt{IsDynamical()}					& \\
\end{tabular}
\end{center}

\texttt{GetMassInv}��\texttt{GetInertiaInv}�͂��ꂼ�ꎿ�ʂ̋t���Ɗ����s��̋t�s���Ԃ��܂��D
\texttt{CompInertia}�́C���̍��̂����`��Ƃ����̖��x�����Ƃɍ��̂̎��ʁC���ʒ��S�Ɗ����s����v�Z���C�ݒ肵�܂��D
\texttt{dynamical}�́C���̍��̂������@���ɏ]�����ǂ������w�肷��t���O�ł��D
����\texttt{dynamical}��\texttt{true}�̏ꍇ�C���̍��̂ɉ����͂��v�Z����C
�j���[�g���̉^���@���ɂ��������č��̂̑��x���ω����܂��D
����C\texttt{dynamical}��\texttt{false}�̏ꍇ�͊O�͂ɂ��e�����󂯂��C�ݒ肳�ꂽ���x�œ����^�����܂��D
����͂��傤�ǁ��̎��ʂ����ꍇ�Ɠ����ł��D


\subsection*{���}

\begin{center}
\begin{tabular}{p{.15\hsize}p{.45\hsize}p{.30\hsize}}
\multicolumn{3}{l}{\texttt{PHSolidDesc}}							\\ \midrule
\texttt{Vec3d}	&	\texttt{velocity}		& ���x					\\
\texttt{Vec3d}	&	\texttt{angVelocity}	& �p���x				\\
\texttt{Posed}	&	\texttt{pose}			& �ʒu�ƌ���			\\
\end{tabular}
\end{center}

\begin{center}
\begin{tabular}{p{.2\hsize}p{.5\hsize}p{.20\hsize}}
\multicolumn{3}{l}{\texttt{PHSolidIf}}									\\ \midrule
\texttt{Vec3d}			& \texttt{GetVelocity()}						& \\
\texttt{void} 			& \texttt{SetVelocity(const Vec3d\&)}			& \\
\texttt{Vec3d} 			& \texttt{GetAngularVelocity()}					& \\
\texttt{void} 			& \texttt{SetAngularVelocity(const Vec3d\&)}	& \\
\texttt{Posed} 			& \texttt{GetPose()}							& \\
\texttt{void} 			& \texttt{SetPose(const Posed\&)}				& \\
\texttt{Vec3d} 			& \texttt{GetFramePosition()}					& \\
\texttt{void} 			& \texttt{SetFramePosition(const Vec3d\&)}		& \\
\texttt{Vec3d} 			& \texttt{GetCenterPosition()}					& \\
\texttt{void} 			& \texttt{SetCenterPosition(const Vec3d\&)}		& \\
\texttt{Quaterniond} 	& \texttt{GetOrientation()}						& \\
\texttt{void} 			& \texttt{SetOrientation(const Quaterniond\&)}	& \\
\end{tabular}
\end{center}

\texttt{velocity}, \texttt{angVelocity}, \texttt{pose}�͂��ꂼ��O���[�o�����W�n�Ɋւ��鍄�̂̑��x�C�p���x�C�ʒu����ь�����\���܂��D
\texttt{[Get|Set]FramePosition}�̓O���[�o�����W�n�Ɋւ��鍄�̂̈ʒu���擾/�ݒ肵�܂��D
����ɑ΂���\texttt{[Get|Set]CenterPosition}�͍��̂̎��ʒ��S�̈ʒu���擾/�ݒ肵�܂��D
�ΐS���Ă��鍄�̂̓��[�J�����W���_�Ǝ��ʒ��S����v���Ȃ����Ƃɒ��ӂ��Ă��������D
\texttt{[Get|Set]Orientation}�̓O���[�o�����W�n�Ɋւ��鍄�̂̌������擾/�ݒ肵�܂��D


\subsection*{�͂̈���Ǝ擾}

���̂ɉ����͂ɂ�
\begin{itemize}
\item ���[�U���ݒ肷��O��
\item �d��
\item �֐߂�ڐG��������S����
\end{itemize}
��$3$��ނ�����C���ꂼ��ɂ��ĕ��i�͂ƃg���N������܂��D
�����ŁC�d�͂͏d�͉����x�ƍ��̂̎��ʂ�茈�܂�C�S���͍͂S�������𖞂����悤�ɓ����Ŏ����I�Ɍv�Z����܂��D
�ȉ��ł̓��[�U�����̂ɉ�����O�͂�ݒ�E�擾������@�������܂��D

\begin{center}
\begin{tabular}{p{.2\hsize}p{.5\hsize}p{.20\hsize}}
\multicolumn{3}{l}{\texttt{PHSolidIf}}								\\ \midrule
\texttt{void} 	& \texttt{AddForce(Vec3d)}					& \\
\texttt{void} 	& \texttt{AddTorque(Vec3d)}					& \\
\texttt{void} 	& \texttt{AddForce(Vec3d, Vec3d)}			& \\
\texttt{Vec3d} 	& \texttt{GetForce()}						& \\
\texttt{Vec3d} 	& \texttt{GetTorque()}						& \\
\end{tabular}
\end{center}

���i�͂�������ɂ�\texttt{AddForce}���g���܂��D
\begin{sourcecode}
solid->AddForce(Vec3d(0.0, -1.0, 0.0));
\end{sourcecode}
�Ƃ���ƍ��̂̎��ʒ��S�ɕ��i��$(0, -1, 0)$�������܂��D�������͂̓O���[�o�����W�n�ŕ\������܂��D
���
\begin{sourcecode}
solid->AddTorque(Vec3d(1.0, 0.0, 0.0));
\end{sourcecode}
�Ƃ���ƍ��̂̎��ʒ��S�Ɋւ��ă��[�����g$(1, 0, 0)$�������܂��D
��p�_��C�ӂɎw�肷��ɂ�
\begin{sourcecode}
solid->AddForce(Vec3d(0.0, -1.0, 0.0), Vec3d(0.0, 0.0, 1.0));
\end{sourcecode}
�Ƃ��܂��D���̏ꍇ�͕��i��$(0, -1, 0)$����p�_$(0, 0, 1)$�ɉ����܂��D
�����ō�p�_�̈ʒu�͍��̂̃��[�J�����W�ł͂Ȃ��O���[�o�����W�ŕ\������邱�Ƃɒ��ӂ��Ă��������D
\texttt{AddForce}��\texttt{AddTorque}�͕�����ĂԂƁC���ꂼ��Ŏw�肵���O�͂̍��͂��ŏI�I�ɍ��̂ɉ����O�͂ƂȂ�܂��D

�O�͂��擾����ɂ�\texttt{GetForce}�C\texttt{GetTorque}���g���܂��D
�������C�����̊֐��Ŏ擾�ł���̂͒��O�̃V�~�����[�V�����X�e�b�v�ō��̂ɍ�p�����O�͂ł��D
���������Ē��O�̃V�~�����[�V�����X�e�b�v���\texttt{AddForce}�����͎͂擾�ł��܂���D
%�V�~�����[�V�����̎��s�Ɨ͂̈���C�擾�Ɋւ���t���[��Fig.\,\ref{fig_addforce}�Ɏ����܂��D


\section{�֐�}

\begin{figure}[t]
\begin{center}
\includegraphics[width=.5\hsize]{fig/phconstraint.eps}
\end{center}
\caption{Constraint class hierarchy}
\label{fig_phconstraint}
\end{figure}

\index{PHConstraint}
\index{PHJoint}
�S���Ƃ͍��̂ƍ��̂̊Ԃɍ�p���Ă��̑��ΓI�^���ɐ����������v�f�ł��D
�S���̃N���X�K�w��Fig.\,\ref{fig_phconstraint}�Ɏ����܂��D
�܂��S���͊֐߂ƐڐG�ɕ�����܂��D�֐߂̓��[�U���쐬���܂����C�ڐG�͏Փ˔��茋�ʂɂ��ƂÂ��Ď����I�ɐ����E�폜����܂��D
�֐߂͂���ɂ������̎�ނɕ������܂��D

�ׂ��Ȑ����͌�񂵂ɂ��āC�܂��͊֐߂̍쐬���@���猩�Ă����܂��D

\subsection*{�֐߂̍쐬}

�ȉ��ł͂����Ƃ��g�p�p�x�̍����q���W�̍쐬���ɂƂ��Ċ֐߂̍쐬���@��������܂��D
�q���W���쐬����ɂ͎��̂悤�ɂ��܂��D
\begin{sourcecode}
PHSolidIf* solid0 = phScene->GetSolids()[0];
PHSolidIf* solid1 = phScene->GetSolids()[1];

PHHingeJointDesc desc;
desc.poseSocket.Pos() = Vec3d( 1.0, 0.0, 0.0);
desc.posePlug.Pos()   = Vec3d(-1.0, 0.0, 0.0);
PHHingeJointIf* joint
    = phScene->CreateJoint(solid0, solid1, desc)->Cast();
\end{sourcecode}
�쐬�������֐߂̎�ނɉ������f�B�X�N���v�^���쐬���C�����\texttt{PHScene}��\texttt{CreateJoint}�֐��ɓn���Ċ֐߂��쐬���܂��D
���̂Ƃ��C�f�B�X�N���v�^�ƂƂ��ɘA�����������̂̃C���^�t�F�[�X���n���܂��D
\texttt{CreateJoint}��\texttt{PHJointIf*}��Ԃ��܂��̂ŁC�쐬�����֐߂̃C���^�t�F�[�X�𓾂�ɂ�\texttt{Cast}�œ��I�L���X�g���܂��D

�֐߂Ɋւ���\texttt{PHScene}�̊֐����ȉ��Ɏ����܂��D

\begin{center}
\begin{tabular}{p{.15\hsize}p{.75\hsize}p{.0\hsize}}
\multicolumn{3}{l}{\texttt{PHSceneIf}}													\\ \midrule
\texttt{PHJointIf*}	& \texttt{CreateJoint(PHSolidIf*, PHSolidIf*, const PHJointDesc\&)}	& \\
\texttt{int}		& \texttt{NJoint()}													& \\
\texttt{PHJointIf*}	& \texttt{GetJoint(int i)}											& \\
\end{tabular}
\end{center}

\texttt{NJoint}�̓V�[�����̊֐߂̌���Ԃ��܂��D\texttt{GetJoint}��\texttt{i}�Ԗڂ̊֐߂��擾���܂��D


\subsection*{�\�P�b�g�ƃv���O}

\index{��������@�\�P�b�g}
\index{�Ղ炮@�v���O}
\begin{figure}[t]
\begin{center}
\begin{tabular}{c}
\includegraphics[clip, width=.5\hsize]{fig/socket_plug1.eps} \\
(a) before connection \\
\\
\includegraphics[clip, width=.5\hsize]{fig/socket_plug2.eps} \\
(b) after connection \\
\end{tabular}
\end{center}
\caption{Socket and plug}
\label{fig_socket_plug}
\end{figure}


���āC��̗�Ńf�B�X�N���v�^�ɒl��ݒ肵�Ă���ӏ��ɒ��ڂ��Ă��������D���̕����Ŋ֐߂̎��t���ʒu���w�肵�Ă��܂��D
Springhead�ł́C�\�P�b�g�ƃv���O�ƌĂ΂�郍�[�J�����W�n��p���Ċ֐߂̎��t���ʒu��\�����܂��D
�\�P�b�g�ƃv���O�Ƃ́C���̖��O����A�z����悤�ɁC�A�����鍄�̂Ɏ��t�������̂悤�Ȃ��̂ł��D
\texttt{CreateJoint}�̑�$1$�����̍��̂Ƀ\�P�b�g�����C��$2$�����̍��̂Ƀv���O�����܂��D
�\�P�b�g�ƃv���O�����ꂼ��̍��̂̂ǂ̈ʒu�Ɏ��t�����邩���w�肷��̂��f�B�X�N���v�^��\texttt{poseSocket}��\texttt{posePlug}�ł��D
��̗�ł̓\�P�b�g�̈ʒu��$(1,0,0)$�C�v���O�̈ʒu��$(-1,0,0)$�ł���(Fig.\,\ref{fig_socket_plug}(a))�D
���̏ꍇ��Fig.\,\ref{fig_socket_plug}(b)�̂悤�ɍ��̂��A������܂��D
��q����悤�ɁC�q���W�̓\�P�b�g�ƃv���O��z������v������S���ł��D
���������ĘA�����ꂽ���̓��m�̓\�P�b�g�ƃv���O��z������]���Ƃ��đ��ΓI�ɉ�]���邱�Ƃ��ł��܂��D

�\�P�b�g�ƃv���O�Ɋւ���f�B�X�N���v�^�ƃC���^�t�F�[�X���Љ�܂��D

\begin{center}
\begin{tabular}{p{.15\hsize}p{.35\hsize}p{.40\hsize}}
\multicolumn{3}{l}{\texttt{PHConstraintDesc}}					\\ \midrule
\texttt{Posed}	&	\texttt{poseSocket}	& �\�P�b�g�̈ʒu�ƌ���	\\
\texttt{Posed}	&	\texttt{posePlug}	& �v���O�̈ʒu�ƌ���	\\
\end{tabular}
\end{center}

\begin{center}
\begin{tabular}{p{.15\hsize}p{.50\hsize}p{.25\hsize}}
\multicolumn{3}{l}{\texttt{PHConstraintIf}}								\\ \midrule
\texttt{PHSolidIf*}	& \texttt{GetSocketSolid()}							& �\�P�b�g���̍��� \\
\texttt{PHSolidIf*} & \texttt{GetPlugSolid()}							& �v���O���̍��� \\
\texttt{void} 		& \texttt{GetSocketPose(Posed\&)}					& \\
\texttt{void} 		& \texttt{SetSocketPose(const Posed\&)}				& \\
\texttt{void} 		& \texttt{GetPlugPose(Posed\&)}						& \\
\texttt{void} 		& \texttt{SetPlugPose(const Posed\&)}				& \\
\texttt{void} 		& \texttt{GetRelativePose(Posed\&)}					& ���ΓI�Ȉʒu�ƌ��� \\
\texttt{void} 		& \texttt{GetRelativeVelocity(Vec3d\&, Vec3d\&)}	& ���Α��x \\
\texttt{void} 		& \texttt{GetConstraintForce(Vec3d\&, Vec3d\&)}		& �S���� \\
\end{tabular}
\end{center}
%	Vec3d GetMotorf();
%	Vec3d GetLimitf();

\texttt{GetRelativePose}�̓\�P�b�g���W�n���猩���v���O���W�n�̑��ΓI�Ȉʒu�ƌ������擾���܂��D
���l�ɁC\texttt{GetRelativeVelocity}�̓\�P�b�g����݂��v���O�̑��Α��x���\�P�b�g���W�n�Ŏ擾���܂��D
�����ő�$1$���������i���x�C��$2$�������p���x�ł��D
\texttt{GetConstraintForce}�͂��̍S�������̂ɉ������S���͂��擾���܂�(��$1$���������i�́C��$2$���������[�����g)�D
��̓I�ɂ́C�\�P�b�g�����̂ɍ�p�����S���͂��\�P�b�g���W�n�ŕ\���������̂������܂��D
�v���O�����̂ɂ͍�p����p�̖@���ɂ���ċt�����̗͂���p���܂����C����𒼐ڎ擾����֐��͗p�ӂ���Ă��܂���D





% --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
\subsection*{�֐߂̎��}

Springhead�Ŏg�p�\�Ȋ֐߂̎�ނ�

\begin{itemize}
\item �q���W (\texttt{PHHingeIf})
\item �X���C�_ (\texttt{PHSliderIf})
\item �p�X�W���C���g (\texttt{PHPathJointIf})
\item �{�[���W���C���g (\texttt{PHBallJointIf})
\item �o�l (\texttt{PHSpringIf})
\end{itemize}

��5��ނł��D��ނ��ƂɁC���R�x�E�S���̎d���E�ψʂ̋��ߕ����قȂ�܂��D


% --- --- --- --- ---
\subsubsection*{�q���W}

\begin{fig}
\epscapopt{phhingejoint}{Hinge joint}{width=0.5\hsize}
\end{fig}

\index{PHHingeJoint}
\index{�Ђ�@�q���W}
�q���W��$1$����]�֐߂ł��D
�q���W�́C\Fig{phhingejoint}�Ɏ����悤�Ƀ\�P�b�g�ƃv���O��z������v����悤�ɍS�����܂��D
���̂Ƃ��\�P�b�g��y���ƃv���O��y���̐����p(x�����m�ł��������Ƃł���)���֐ߕψʂƂȂ�܂��D

�֐ߕψʂ��擾����API��$1$���R�x�֐�(\texttt{PH1DJointIf})�ŋ��ʂł��D���̂��߃q���W�Ɍ��炸�X���C�_�E�p�X�W���C���g�ł��g�p�ł��܂��D

\begin{reference}{PH1DJointIf}
\classmember{double GetPosition()}
�֐߂̕ψʂ��擾���܂��D�ψʂ̂͂�����͊֐߂̎�ނɈˑ����܂��D
\end{reference}

% --- --- --- --- ---
\subsubsection*{�X���C�_}

\begin{fig}
\epscapopt{phsliderjoint}{Slider joint}{width=0.5\hsize}
\end{fig}

\index{PHSliderJoint}
\index{���炢��@�X���C�_}
�X���C�_��$1$���R�x�̒����֐߂ł��D
�X���C�_�́C\Fig{phsliderjoint}�Ɏ����悤�Ƀ\�P�b�g�ƃv���O��z�������꒼����ɏ��C�����҂�x���Cy�������������������悤�ɍS�����܂��D
���̂Ƃ��\�P�b�g�̌��_����v���O�̌��_�܂ł��֐ߕψʂƂȂ�܂��D



% --- --- --- --- ---
\subsubsection*{�p�X�W���C���g}

\index{PHPathJoint}
\index{�ς����傢���@�p�X�W���C���g}
�p�X�W���C���g�̓\�P�b�g�ƃv���O�̑��Έʒu�֌W��$1$�p�����[�^�̎��R�Ȑ��ŕ\������֐߂ł��D�ڂ����͌�q���܂��D

T.B.D.



% --- --- --- --- ---
\subsubsection*{�{�[���W���C���g}

\begin{fig}
  \begin{tabular}{cc}
    \epsopt{phballjoint}{width=0.45\hsize} & \epsopt{swingtwist}{width=0.35\hsize} \\
    (a) & (b)
  \end{tabular}
  \labelcap{phballjoint}{Ball Joint}
\end{fig}

\index{PHBallJoint}
\index{�ځ[�邶�傢���@�{�[���W���C���g}
�{�[���W���C���g��$3$���R�x�̉�]�֐߂ł��D
�{�[���W���C���g��\Fig{phballjoint}(a)�Ɏ����悤�Ƀ\�P�b�g�ƃv���O�̌��_����v����悤�ɍS�����܂��D
�\�P�b�g���W�n���v���O���W�n�ɕϊ�����悤�ȃN�H�[�^�j�I�����ψʂƂȂ�܂��D

����ŁC�{�[���W���C���g�̕ψʂ̓I�C���[�p�̈��ł���Swing-Twist���W�n(\Fig{phballjoint}(b))�Ŏ擾���邱�Ƃ��ł��܂��D
�\�P�b�g�ƃv���O��z�����m���Ȃ��p���X�C���O�p(Swing)�C�v���O��z�����\�P�b�g��x-y���ʂւ̎ˉe���\�P�b�g��x���ƂȂ��p���X�C���O���ʊp(Swing-Dir)�C�v���O��z������̉�]�p�x���c�C�X�g�p(Twist)�ƌĂт܂��DSwing-Twist���W�n�́C��q����{�[���W���C���g�̊֐߉��͈͂̎w��ɗp���܂��D

����2��ނ̕ψʂ́C���ꂼ��ɑΉ������֐��Ŏ擾���邱�Ƃ��ł��܂��D
\begin{reference}{PHBallJoint}
\classmember{Quaterniond GetPosition()}
�\�P�b�g���W�n���v���O���W�n�ɕϊ�����悤�ȃN�H�[�^�j�I����Ԃ��܂��D

\classmember{Vec3d GetAngle()}
Swing-Twist���W�n�ŕ\�����ꂽ�֐ߕψʂ�Ԃ��܂��D
\end{reference}


\subsubsection*{�o�l}

\index{PHSpring}
\index{�΂�@�o�l}

\begin{fig}
\epscapopt{phspring}{Spring}{width=0.5\hsize}
\end{fig}

���̊Ԃ�A������_���p�t���o�l�ł��D�\�P�b�g���W�n�ƃv���O���W�n����v����Ƃ������R��ԂŁC�ʒu�̕ψʁE�p���̕ψʂɔ�Ⴕ�Ď��R��Ԃɖ߂��悤�ȗ́E���[�����g�𔭐����܂��D���i�^���ɍ�p����o�l�E�_���p�W���ƁC��]�^���ɍ�p����o�l�E�_���p�W���̓f�B�X�N���v�^�ɂ���Ă��ꂼ��ݒ�ł��܂��D

\begin{lightreference}{PHSpringDesc}
\member{Vec3d spring}{���i�^���ɑ΂���o�l�W��}
\member{Vec3d damper}{���i�^���ɑ΂���_���p�W��}
\member{double springOri}{��]�^���ɑ΂���o�l�W��}
\member{double damperOri}{��]�^���ɑ΂���_���p�W��}
\end{lightreference}


\subsection*{�L�����Ɩ�����}

\begin{center}
\begin{tabular}{p{.15\hsize}p{.45\hsize}p{.30\hsize}}
\multicolumn{3}{l}{\texttt{PHConstraintDesc}}					\\ \midrule
\texttt{bool}	&	\texttt{bEnabled}	& �L��/�����t���O		\\
\end{tabular}
\end{center}

\begin{center}
\begin{tabular}{p{.15\hsize}p{.50\hsize}p{.25\hsize}}
\multicolumn{3}{l}{\texttt{PHConstraintIf}}						\\ \midrule
\texttt{void}	& \texttt{Enable(bool)}					& \\
\texttt{bool} 	& \texttt{IsEnabled()}					& \\
\end{tabular}
\end{center}

�L���ȍS���͍S���͂𐶂��܂��D���������ꂽ�S���͑��݂��Ȃ��̂Ɠ�����ԂɂȂ�܂����C
�폜����̂ƈقȂ肢�ł��ēx�L�������邱�Ƃ��ł��܂��D
�쐬����̍S���͗L��������Ă��܂��D





\subsection*{�֐ߐ���}

\subsubsection*{$1$���R�x�֐߂̏ꍇ}

\begin{center}
\begin{tabular}{p{.15\hsize}p{.45\hsize}p{.30\hsize}}
\multicolumn{3}{l}{\texttt{PHJoint1DDesc}}								\\ \midrule
\texttt{double}	&	\texttt{spring}			& ���͈͉���				\\
\texttt{double}	&	\texttt{damper}			& ���͈͏��				\\
\texttt{double}	&	\texttt{targetPosition}	& ���͈͐����p�o�l�W��	\\
\texttt{double}	&	\texttt{targetVelocity}	& ���͈͐����p�_���p�W��	\\
\texttt{double}	&	\texttt{offsetForce}	& \\
\texttt{double}	&	\texttt{fMax}			& \\
\end{tabular}
\end{center}

\begin{center}
\begin{longtable}{p{.15\hsize}p{.45\hsize}p{.30\hsize}}
\multicolumn{3}{l}{\texttt{PHJoint1DIf}}						\\ \midrule
\texttt{double}	& \texttt{GetPosition()}				& �֐ߕψʂ��擾 \\
\texttt{double} & \texttt{GetVelocity()}				& �֐ߑ��x���擾 \\
\texttt{void} 	& \texttt{SetSpring(double)}			& \\
\texttt{double} & \texttt{GetSpring()}					& \\
\texttt{void} 	& \texttt{SetDamper(double)}			& \\
\texttt{double} & \texttt{GetDamper()}					& \\
\texttt{void} 	& \texttt{SetTargetPosition(double)}	& \\
\texttt{double} & \texttt{GetTargetPosition()}			& \\
\texttt{void} 	& \texttt{SetTargetVelocity(double)}	& \\
\texttt{double} & \texttt{GetTargetVelocity()}			& \\
\texttt{void} 	& \texttt{SetOffsetForce(double)}		& \\
\texttt{double} & \texttt{GetOffsetForce()}				& \\
\texttt{void} 	& \texttt{SetTorqueMax(double)}			& �ő�֐߃g���N��ݒ� \\
\texttt{double} & \texttt{GetTorqueMax()}				& �ő�֐߃g���N���擾 \\
\end{longtable}
\end{center}

�֐߂��쓮�����$f$�͎����ŗ^�����܂��D
\begin{align*}
f = K(p_0 - p) + D(v_0 - v) + f_0
\end{align*}
������$p$�C$v$�͂��ꂼ��֐ߕψʂƊ֐ߑ��x��\texttt{GetPosition}�C\texttt{GetVelocity}�Ŏ擾�ł��܂��D
���̑��̋L���ƃf�B�X�N���v�^�ϐ��Ƃ̑Ή��͈ȉ��̒ʂ�ł��D
\begin{center}
\begin{tabular}{ll}
$K$		&	\texttt{spring}				\\
$D$		&	\texttt{damper}				\\
$p_0$	&	\texttt{targetPosition}		\\
$v_0$	&	\texttt{targetVelocity}		\\
$f_0$	&	\texttt{offsetForce}
\end{tabular}
\end{center}
��̎��̓o�l�E�_���p���f����PD���䑥�̓�ʂ�̉��߂��ł��܂��D
�O�҂Ƃ��ĂƂ炦��Ȃ�$K$�̓o�l�W���C$D$�̓_���p�W���C$p_0$�̓o�l�̎��R���C$v_0$�͊���x�ƂȂ�܂��D
��҂Ƃ��ĂƂ炦��ꍇ��$K$��P�Q�C���C$D$��D�Q�C���C$p_0$�͖ڕW�ψʁC$v_0$�͖ڕW���x�ƂȂ�܂��D
�܂��C$f_0$�͊֐߃g���N�̃I�t�Z�b�g���ł��D
��̎��œ���ꂽ�֐߃g���N�͍Ō��$\pm$\texttt{fMax}�͈̔͂Ɏ��܂�悤�ɃN�����v����܂��D

\subsubsection*{�{�[���W���C���g�̏ꍇ}

�q���W�Ɠ��l�ɁC�o�l�_���p���f���EPD������������܂��D
�{�[���W���C���g�̕ψʂ̓N�H�[�^�j�I���ŕ\����邽�߁C�ڕW�ψ�\texttt{targetPosition}�̓N�H�[�^�j�I���ŁC�ڕW���x\texttt{targetVelocity}�͉�]�x�N�g���ŗ^���܂��D

\begin{lightreference}{PHBallJointDesc}
\member{double spring}{�o�l�W��}
\member{double damper}{�_���p�W��}
\member{Quaterniond targetPosition}{�ڕW�ψ�}
\member{Vec3d targetVelocity}{�ڕW���x}
\member{Vec3d offsetForce}{���[�^�[�g���N}
\member{double fMax}{�֐߃g���N�̌��x}
\end{lightreference}



	%\multicolumn{2}{l}{\texttt{void SetMotorTorque(double)}}		& \\
	%\multicolumn{2}{l}{\texttt{double GetMotorTorque()}}	& \\

	%double	secondDamper;	///< ��ڂ̃_���p�W��
	%double  yieldStress;	///< �~������
	%double  hardnessRate;	///< �~�����͈ȉ��̏ꍇ�ɓ�ڂ̃_���p�W���Ɋ|����䗦

	%void SetTrajectoryVelocity(double v);
	%double GetTrajectoryVelocity();
	%double  GetSecondDamper();
	%void	SetSecondDamper(double input);
	%double GetYieldStress();
    %void SetYieldStress(const double yS);
	%double GetHardnessRate();
	%void SetHardnessRate(const double hR);
	%PHJointDesc::PHDeformationType 	GetDeformationMode();





% --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
\subsection*{���搧��}

\texttt{CreateLimit}�͉��͈͐���I�u�W�F�N�g�̃f�B�X�N���v�^�������ɂƂ�܂��D
$1$���R�x�֐߂̉��͈͐���̏ꍇ�C\texttt{Vec2d range}�������\���܂��D\texttt{range[0]}������̉����C\texttt{range[1]}������ł��D\texttt{range[0] < range[1]}����������Ă���Ƃ��Ɍ�����͈͐��񂪗L���ƂȂ�܂��D
�f�t�H���g�ł�\texttt{range[0] > range[1]}�ƂȂ�l���ݒ肳��Ă��āC���͈͐���͖����ƂȂ��Ă��܂��D

�֐߂̕ψʂ����͈͌��E�ɓ��B�����Ƃ��C�͈͂𒴉߂��Ȃ��悤�ɉ��͈͐���̍S���͂���p���܂��D
���̂Ƃ��C�֐ߕψʂ�͈͓��ɉ����߂��͂̓o�l�E�_���p���f���Ōv�Z����܂��D
���̃o�l�W���ƃ_���p�W���͂��ꂼ��f�B�X�N���v�^��\texttt{spring}�C\texttt{damper}�Ŏw�肵�܂��D

\begin{tips}
���͈͗p��\texttt{spring}�C\texttt{damper}�͏����l�ł��\���傫�Ȓl���ݒ肳��Ă��܂����C�֐ߐ���ɂ����Ĕ��ɑ傫�ȃo�l�E�_���p�W����p����Ɖ��͈͐���̃o�l�E�_���p�������Ă��܂����Ƃ�����܂��D���̏ꍇ�ɂ͊֐ߐ�����傫�ȌW����K�؂ɍĐݒ肷��ƁC���͈͓��Ŋ֐߂𐧌䂷�鎖���ł���悤�ɂȂ�܂��D
\end{tips}


\subsubsection*{$1$���R�x�֐߂̏ꍇ}

\begin{reference}{PH1DJointLimitDesc}
\classmember{Vec2d range}
���͈͂�\���܂��D\texttt{range[0]}�������C\texttt{range[1]}������ł��D

\classmember{double spring} \Plus
\classmember{double damper}
���͈͂𐧌����邽�߂̃o�l�E�_���p���f���̌W���ł��D
\end{reference}

\begin{reference}{PH1DJointLimitIf}
\classmember{IsOnLimit()}
���݂̊֐ߎp�������͈͊O�ɂ��鎞��\texttt{true}��Ԃ��܂��D���̊֐���\texttt{true}��Ԃ��悤�Ȏ��C�֐߂ɂ͉��搧����������邽�߂̍S���͂��������Ă��܂��D
\end{reference}


\subsubsection*{�{�[���W���C���g�̏ꍇ}

�{�[���W���C���g�̉��͈͂�\Fig{phballjoint}(b)�Ɏ���Swing-Twist���W�n�ɂ���Ďw�肵�܂��D

�{�[���W���C���g�ɑ΂��Ă�2��ނ̉��͈͐�����g�p���邱�Ƃ��ł��܂��D
\begin{itemize}
\item \texttt{ConeLimit}�͉~���`�̉��͈͐���ŁC��Ɋ֐߂̃X�C���O�p�����͈͓��ɐ��񂵂܂��D
\item \texttt{SplineLimit}�͎��R�Ȑ��`�̉��͈͐���ŁC�v���O���W�nz���̉��͈͂�Ȑ��Ŏw�肷�邱�Ƃ��ł��܂��D
\end{itemize}

�����ł�\texttt{ConeLimit}�ɂ��Đ������܂�(\texttt{SplineLimit}�ɂ��Ă͌�q���܂�)�D

\begin{reference}{PHBallJointConeLimitDesc}
\classmember{Vec2d limitSwing}
�X�C���O�p�̉��͈͂ł��D�T�O�I�ɂ́C�֐߂����ȏ�ɐ܂�Ȃ���Ȃ��悤�ɂ��鐧��ł�(�X�C���O�p�̉�����ݒ肷�鎖���ł���̂ŁC���ۂɂ͈��ȏ�ɂ܂������ɂȂ�Ȃ��悤�ɂ���@�\���L���Ă��܂�)�D

\texttt{limitSwing[0]}�������C\texttt{limitSwing[1]}������ł��D\texttt{limitSwing}���擾�E�ݒ肷�邽�߂�API��
\begin{quote}
\texttt{PHBallJointConeLimitIf::[Set|Get]SwingRange(range)}
\end{quote}
�ł��D

\texttt{limitSwing[0] > limitSwing[1]}�ƂȂ鎞�͖���������܂��D�f�t�H���g�ł�\texttt{limitSwing[0] > limitSwing[1]}�ƂȂ�l���Z�b�g����Ă��܂��D

\classmember{Vec2d limitTwist}
�c�C�X�g�p�̉��͈͂ł��D�T�O�I�ɂ́C�֐߂����ȏ�ɂ˂���Ȃ��悤�ɂ��邽�߂̐���ł��D

\texttt{limitTwist[0]}�������C\texttt{limitTwist[1]}������ł��D\texttt{limitTwist}���擾�E�ݒ肷�邽�߂�API��
\begin{quote}
\texttt{PHBallJointConeLimitIf::[Set|Get]TwistRange(range)}
\end{quote}
�ł��D

\texttt{limitTwist[0] > limitTwist[1]}�ƂȂ鎞�͖���������܂��D�f�t�H���g�ł�\texttt{limitTwist[0] > limitTwist[1]}�ƂȂ�l���Z�b�g����Ă��܂��D

\classmember{double spring} \Plus
\classmember{double damper}
���͈͂𐧌����邽�߂̃o�l�E�_���p���f���̌W���ł��D$1$���R�x�֐߂̏ꍇ�Ɠ����ł��D
\end{reference}

\begin{reference}{PHBallJointConeLimitIf}
\classmember{IsOnLimit()}
���݂̊֐ߎp�������͈͊O�ɂ��鎞��\texttt{true}��Ԃ��܂��D$1$���R�x�֐߂̏ꍇ�Ɠ����ł��D
\end{reference}



% --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
\subsection*{�{�[���W���C���g�̎��R�Ȑ�����} \label{sec_splinelimit}





% --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
\subsection*{�p�X�W���C���g} \label{sec_phpathjoint}



% --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
\subsection*{�e�Y���ό`�o�l�_���p}







\section{�֐ߌn�̋t�^���w}

% ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
%
% �T��
% 

�t�^���w(IK)�́C���̊֐ߌn�ɂ����č��̂��ڕW�ʒu�ɓ��B����悤�֐߂𐧌䂷��@�\�ł��D

Springhead�ł́C�֐ߌn�̃��R�r�A����p����IK�@�\���g�p�\�ł��D
�����V�~�����[�V������1�X�e�b�v���ƂɊ֐ߌn�̃��R�r�A�����v�Z���C����Ɋ�Â��č��̂�ڕW�ʒu�E�p���ɋ߂Â���悤�Ȋe�֐߂̊p���x���v�Z���܂��D
�V�~�����[�V�����𑱂��邱�ƂŁC�ŏI�I�ɍ��̂��ڕW�ʒu�E�p���ƂȂ�����Ԃ������܂��D

Springhead��̍��̊֐ߌn�ɑ΂���IK���g�p����ɂ́C���X���������K�v�ł��D
���̂悤��3�̍��̂�������ɂȂ������֐ߌn���ɂƂ��ĉ�����܂��D

\begin{center}
\epsopt{ikexample3link}{width=0.5\hsize}
\end{center}


% ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
%
% ��
% 

IK���g�p����ɂ́C�܂�IK�ɗp���邽�߂̊֐߂��u�A�N�`���G�[�^�v�Ƃ��ēo�^����K�v������܂��D
\begin{sourcecode}
// given PHSceneIf* phScene
// given PHSolidIf* solid1, solid2, solid3
// given PHHingeJointIf* joint1 (solid1 <-> solid2)
// given PHHingeJointIf* joint2 (solid2 <-> solid3)

PHIKHingeActuatorDesc descIKActuator;

PHIKHingeActuatorIf* ikActuator1
  = phScene->CreateIKActuator(descIKActuator);
ikActuator1.AddChildObject(joint1);

PHIKHingeActuatorIf* ikActuator2
  = phScene->CreateIKActuator(descIKActuator);
ikActuator1.AddChildObject(joint2);
\end{sourcecode}
\texttt{PHIKHingeActuatorIf}��\texttt{PHHingeJointIf}�ɑΉ�����A�N�`���G�[�^�N���X�ł��D


���ɁC�֐ߌn�̐e�q�֌W��o�^���܂��D�e�A�N�`���G�[�^�ɁC�q�A�N�`���G�[�^��o�^���܂��D
\begin{sourcecode}
ikActuator1.AddChildObject(ikActuator2);
\end{sourcecode}


�܂��CIK��p���ē��B�������[�̍��̂��u�G���h�G�t�F�N�^�v�Ƃ��ēo�^����K�v������܂��D
\begin{sourcecode}
PHIKEndEffectorDesc descEndEffector;

PHIKEndEffectorIf* ikEndEffector1
  = phScene->CreateIKEndEffector(descEndEffector);
ikEndEffector1.AddChildObject(solid3);
\end{sourcecode}


�Ō�ɁC���̊֐ߌn�̐e�q�֌W�ɂ����āC�G���h�G�t�F�N�^�̒��ڂ̐e�ɂ�����A�N�`���G�[�^�ɑ΂��C�G���h�G�t�F�N�^��o�^���܂��D
\begin{sourcecode}
ikActuator2.AddChildObject(ikEndEffector1);
\end{sourcecode}
���̗�ł� \texttt{solid1 -(joint1)-> solid2 -(joint2)-> solid3} �̂悤�Ɋ֐߂��ڑ�����Ă��܂�����C�֐ߌn�̖��[�ł��� \texttt{solid3} ���G���h�G�t�F�N�^�ɂ����ꍇ�C���ڂ̐e�ɂ�����A�N�`���G�[�^�� \texttt{joint2} �ɑΉ�����A�N�`���G�[�^�C���Ȃ킿 \texttt{ikActuator2} �Ƃ������ƂɂȂ�܂��D

�����܂ł̍�ƂŁC�������ꂽ�I�u�W�F�N�g�̊֌W�͈ȉ��̂悤�ɂȂ��Ă���͂��ł��D
\begin{center}
\epsopt{ikexample3linkobjects}{width=0.9\hsize}
\end{center}
����ŉ������͏I���ł��D

�ڕW�ʒu���Z�b�g���CIK�G���W����L���ɂ����IK�������n�߂܂��D
\begin{sourcecode}
// solid3 goes to (2, 5, 0)
ikEndEffector1->SetTargetPosition(Vec3d(2, 5, 0)); 

phScene->GetIKEngine()->Enable(true);

...
phScene->Step(); // IK is calculated in physics step
...
\end{sourcecode}

% ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
%
% �ڍ�
% 

% ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- 
\subsection*{IK�G���W��}
% �T��

IK�̌v�Z�́C\texttt{PHScene}������IK�G���W��(\texttt{PHIKEngine})�ɂ���Ď�������Ă��܂��D

IK�G���W���̓f�t�H���g�ł͖����ƂȂ��Ă��܂��D
\begin{sourcecode}
phScene->GetIKEngine()->Enable(true);
\end{sourcecode}
�����s���邱�ƂŗL���ƂȂ�܂��D\texttt{GetIKEngine()}�́C\texttt{PHScene}������IK�G���W�����擾����API�ł��D

Springhead�ɂ�����IK�̌v�Z�����́C�֐ߌn�̃��R�r�s��i���R�r�A���j�Ɋ�Â��܂��D�S�A�N�`���G�[�^�̊֐ߊp�x�ɔ����ω��� $\varDelta\bm{\theta}$ ��^�������́C�S�G���h�G�t�F�N�^�̈ʒu�̔����ω��� $\varDelta\bm{r}$ �́C�֐ߌn�̃��R�r�A�� $J$ ��p����
\[
\varDelta\bm{r} = J \varDelta\bm{\theta}
\]
�ƕ\����܂��D���X�e�b�v���ƂɊ֐ߌn���R�r�A��$J$����іڕW�ʒu�Ɍ����������ψ�$\varDelta\bm{r}$���v�Z���C��L�̐��`�A�����������������ƂŊe�֐߂ɗ^����p���x�����߂܂��D

���`�A���������̋����ɂ̓K�E�X=�U�C�f���@�ɂ��J��Ԃ���@��p���Ă��܂��D���̂���1�X�e�b�v������̌J��Ԃ��v�Z�̉񐔂ɂ���Čv�Z���x�ƌv�Z���x�̃g���[�h�I�t������܂��D�J��Ԃ��̉񐔂́C
\begin{sourcecode}
// 20 iteration per 1 physics step
phScene->GetIKEngine()->SetNumIter(20);
\end{sourcecode}
�̂悤�ɂ��Đݒ肷�邱�Ƃ��ł��܂��D

% ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- 
% ���t�@�����X
\referencetitle

\begin{reference}{PHSceneIf}
\classmember{PHIKEngineIf* GetIKEngine()}
IK�G���W�����擾���܂��D
\end{reference}

\begin{reference}{PHIKEngineIf}
\classmember{Enable(bool b)}
IK�G���W���̗L���E������؂�ւ��܂��D������\texttt{true}�Ȃ�ΗL�������C\texttt{false}�Ȃ�Ζ��������܂��D

\classmember{SetNumIter(int n)}
IK�̌J��Ԃ��v�Z�񐔂�1�X�e�b�v������\texttt{n}��ɃZ�b�g���܂��D
\end{reference}



% ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- 
\subsection*{�A�N�`���G�[�^}
% �T��

Springhead�ł́CIK�Ɏg�p����e�֐߂��A�N�`���G�[�^�ƌĂт܂��DIK�́C�A�N�`���G�[�^���쓮�����č��̂�ڕW�ʒu�ɓ��B�����܂��D

���I�u�W�F�N�g�֌W�}��

IK�G���W���̓A�N�`���G�[�^�𕡐��ێ����C�e�A�N�`���G�[�^���e�֐߂�ێ����܂��D�A�N�`���G�[�^�I�u�W�F�N�g��ɂ��C�֐߂���Ή����܂��D
�A�N�`���G�[�^�I�u�W�F�N�g�̋�̓I�Ȗ����́C�֐߂̏�Ԃ�IK�G���W���ɓ`���CIK�̌v�Z�̂����֐߃��R�r�A���̌v�Z�ȂǊ֐߂��Ƃɍs�����������s���CIK�̌v�Z���ʂɏ]���Ċ֐߂𓮂������ł��D


% ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- 
% �ڍ�
\subsubsection*{�A�N�`���G�[�^�N���X�̎�ނƍ쐬}

�{�e���M���_�ł́CIK�p�A�N�`���G�[�^�Ƃ��Ďg�p�ł���̂̓q���W�ƃ{�[���W���C���g�݂̂ł��D
���ꂼ��ɑΉ������A�N�`���G�[�^�N���X������܂��D

\begin{itemize}
\item \texttt{PHIKHingeActuator}��\texttt{PHHingeJoint}�ɑ΂���A�N�`���G�[�^�ł��D�q���W�W���C���g��1���R�x���쓮�ɗp���܂��D

\item \texttt{PHIKBallActuator}��\texttt{PHBallJoint}�ɑ΂���A�N�`���G�[�^�ł��D�{�[���W���C���g��3���R�x�̊֐߂ł����C��q����G���h�G�t�F�N�^�̎p��������s��Ȃ�(�G���h�G�t�F�N�^�̈ʒu�݂̂𐧌䂷��)�ꍇ�́C�G���h�G�t�F�N�^�̈ʒu��ω������邱�Ƃ̂ł���2���R�x�݂̂��쓮�ɗp���܂�(�g�p����2���R�x�̎���1�X�e�b�v���ƂɍX�V����܂�)�D
\end{itemize}

\begin{sourcecode}
// given PHSceneIf* phScene

PHIKHingeActuatorDesc descIKActuator;
PHIKHingeActuatorIf* ikActuator
    = phScene->CreateIKActuator(descActuator);
\end{sourcecode}
�A�N�`���G�[�^���쐬����ɂ́C\texttt{PHSceneIf}��\texttt{CreateIKActuator}�֐���p���܂��D�����̓A�N�`���G�[�^�̃f�B�X�N���v�^�ł��D\texttt{PHIKHingeActuatorDesc}�^�̃f�B�X�N���v�^��n���ƃq���W�p�̃A�N�`���G�[�^���쐬����C\texttt{PHIKBallActuatorDesc}�^�̃f�B�X�N���v�^��n���ƃ{�[���W���C���g�p�̃A�N�`���G�[�^���쐬����܂��D

�쐬���ꂽ���_�ł́C�A�N�`���G�[�^�͊֐߂ƑΉ��t��������Ă��܂���D�A�N�`���G�[�^�̎q�v�f�Ɋ֐߂�o�^���邱�ƂőΉ��t�����s���܂��D
\begin{sourcecode}
// given PHHingeJointIf* joint
ikActuator->AddChildObject(joint);
\end{sourcecode}


% ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- 
% �ڍ�
\subsubsection*{�A�N�`���G�[�^�̐e�q�֌W�̓o�^}

���̂悤�ɓ�҂ɕ��򂵂������N���ɂƂ�܂��F

\begin{center}
\epsopt{ikexample5link}{width=0.8\hsize}
\end{center}

�v�Z��CIK�ŋ쓮����֐ߌn�͖؍\���łȂ���΂Ȃ�܂���D
Springhead�ł́C�A�N�`���G�[�^�̐e�q�֌W����邱�ƂŊ֐߂̖؍\����ݒ肵�܂��D

\begin{sourcecode}
// given PHIKActuator ikActuator1, ikActuator2
ikActuator1->AddChildObject(ikActuator2);
\end{sourcecode}
\texttt{AddChildObject}���Ăяo���ƁC�A�N�`���G�[�^�ɑ΂��u�q�v�f�v�ƂȂ�A�N�`���G�[�^��o�^���邱�Ƃ��ł��܂��D
�����S�ẴA�N�`���G�[�^�ɑ΂��čs�����ƂŃA�N�`���G�[�^�̖؍\�����ݒ肳��܂��D���̂Ƃ��A�N�`���G�[�^�̐e�q�֌W�́C�O�o�̐}�̉E���̂悤�ɂȂ�܂��D


% ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- 
% �ڍ�
\subsubsection*{�֐߂̃_���p�W����IK}

%%% �ʒu���[�h�t���邩������܂���D�{�����[�X�܂łɌ��߂邱�ƁD %%%

�֐߂̉^���́CIK�@�\�ɂ���Čv�Z���ꂽ�ڕW�֐ߊp���x���֐߂�\texttt{SetTargetVelocity}���邱�ƂŎ������܂��D
�ڕW���x�Ɋւ���֐߂̐U�镑���́C�֐߂�\texttt{damper}�p�����[�^�ɂ���ĕω����܂��D��ʂ�\texttt{damper}���傫���قǊ֐߂͌ł��Ȃ�C�O���̉e�����󂯂Â炭�Ȃ�܂��D���̐����͂��̂܂�IK�̐U�镑���ɂ��󂯌p����܂��D


% ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- 
% �ڍ�
\subsubsection*{�d�ݕt��IK}

�ʏ�CIK�͑S�Ă̊֐߂��\�Ȍ���ϓ��Ɏg�p���ĖڕW��B������悤�v�Z����܂��D
����C�L�����N�^�̓���ɗp����ꍇ�ȂǂŁC����D��I�ɓ��������̂͂��܂蓮�����Ȃ��C�Ƃ������d�ݕt�����v��������ʂ�����܂��D

Springhead��IK�ɂ́C���̂悤�ȏd�ݕt����ݒ肷�邱�Ƃ��ł��܂��D
\begin{sourcecode}
// given PHIKActuator ikActuator1, ikActuator2
ikActuator1->SetBias(2.0);
ikActuator2->SetBias(1.0);
\end{sourcecode}
\texttt{SetBias}�́C�w�肵���֐߂����܂蓮�����Ȃ��悤�ɐݒ肷��֐��ł��DBias�ɂ�$1.0$�ȏ�̒l��ݒ肵�܂��D�傫�Ȓl��ݒ肵���֐߂قǁCIK�ɂ�铮��͏������Ȃ�܂��D�f�t�H���g�ł͂ǂ̃A�N�`���G�[�^��$1.0$�ƂȂ��Ă���C�S�֐߂��ϓ��Ɏg�p����܂��D

% ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- 
% ���t�@�����X�i�A�N�`���G�[�^�j





% ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- 
\subsection*{�G���h�G�t�F�N�^}
% �T��

���́E�֐ߌn���\�����鍄�̂̈ꕔ���C�u�G���h�G�t�F�N�^�v�Ɏw�肷�邱�Ƃ��ł��܂��D
�G���h�G�t�F�N�^�ɂ͖ڕW�ʒu�E�p�����w�����邱�Ƃ��ł��܂��DIK�G���W���́C�G���h�G�t�F�N�^���̂��w�肳�ꂽ�ڕW�ʒu�E�p����B������悤�A�N�`���G�[�^�𐧌䂵�܂��D


% ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- 
% �ڍ�
\subsubsection*{�G���h�G�t�F�N�^�̍쐬}

�G���h�G�t�F�N�^��\texttt{PHSceneIf}��\texttt{CreateIKEndEffector}��p���č쐬���܂��D�����ɂ�\texttt{PHIKEndEffectorDesc}��n���܂��D
\begin{sourcecode}
// given PHSceneIf* phScene

PHIKEndEffectorDesc descEndEffector;

PHIKEndEffectorIf* ikEndEffector
  = phScene->CreateIKEndEffector(descEndEffector);
\end{sourcecode}

�A�N�`���G�[�^���l�C�G���h�G�t�F�N�^���쐬���_�ł͍��̂Ƃ̑Ή��������܂���D\texttt{AddChildObject}�ɂ�荄�̂��q�v�f�Ƃ��ēo�^����K�v������܂��D
\begin{sourcecode}
// given PHSolidIf* solid

ikEndEffector.AddChildObject(solid);
\end{sourcecode}

���ɁC�G���h�G�t�F�N�^���̂�e���̂ɘA�����Ă���A�N�`���G�[�^�ɑ΂��C�G���h�G�t�F�N�^���q�v�f�Ƃ��ēo�^���܂��D
\begin{sourcecode}
// given PHIKActuatorIf* ikActuatorParent

ikActuatorParent.AddChildObject(ikEndEffector);
\end{sourcecode}
�������邱�ƂŃG���h�G�t�F�N�^�̓A�N�`���G�[�^�؍\���̗t�m�[�h�ƂȂ�CIK�̌v�Z�Ɏg�p�ł���悤�ɂȂ�܂��D

�Ȃ��C�G���h�G�t�F�N�^�͈�̊֐ߌn�ɑ΂��ĕ����쐬���邱�Ƃ��ł��܂��D���̏ꍇ�CIK�͕����̃G���h�G�t�F�N�^���\�Ȍ��蓯���ɖڕW�ʒu�E�p����B���ł���悤�A�N�`���G�[�^�𐧌䂵�܂��D�܂��C�G���h�G�t�F�N�^�͊֐ߌn�̐�[���̂Ɍ���܂���D


% ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- 
% �ڍ�
\subsubsection*{�ڕW�ʒu�̐ݒ�}

�G���h�G�t�F�N�^�̖ڕW�ʒu��\texttt{SetTargetPosition}�ɂ���Ďw�肵�܂��D
\begin{sourcecode}
// solid3 goes to (2, 5, 0)
ikEndEffector->SetTargetPosition(Vec3d(2, 5, 0)); 
\end{sourcecode}

�G���h�G�t�F�N�^�ɖڕW�p�����w�����C�G���h�G�t�F�N�^������̎p�����Ƃ�悤�Ɋ֐ߌn�𓮍삳���邱�Ƃ��ł��܂��D
\begin{sourcecode}
ikEndEffector->SetTargetOrientation( Quaterniond::Rot('x', rad(30)) ); 
ikEndEffector->EnableOrientationControl(true);
\end{sourcecode}
�ڕW�p����\texttt{Quaterniond}�Őݒ肵�܂��D�p������̓f�t�H���g�ł͖����ɂȂ��Ă���C�g�p����ɂ�\texttt{EnableOrientationControl}���Ă�ŗL��������K�v������܂��D

\texttt{EnablePositionControl}�����\texttt{EnableOrientationControl}��p����ƁC�ʒu����E�p������̗������ʂɗL���E���������邱�Ƃ��ł��܂��D
\begin{sourcecode}
// �ʒu���䂠��C�p������Ȃ��i�f�t�H���g�j
ikEndEffector->EnablePositionControl(true);
ikEndEffector->EnableOrientationControl(false);
\end{sourcecode}

\begin{sourcecode}
// �ʒu����Ȃ��C�p�����䂠��
ikEndEffector->EnablePositionControl(false);
ikEndEffector->EnableOrientationControl(true);
\end{sourcecode}

\begin{sourcecode}
// �ʒu���䂠��C�p�����䂠��
ikEndEffector->EnablePositionControl(true);
ikEndEffector->EnableOrientationControl(true);
\end{sourcecode}


% ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- 
% ���t�@�����X�i�G���h�G�t�F�N�^�j

\section{�ڐG}
\label{sec_physics_contact}

\index{�������傭@�ڐG}

\subsection*{�ڐG���f��}

\begin{figure}[t]
\begin{center}
\begin{tabular}{c}
\includegraphics[clip, width=.7\hsize]{fig/phcontact.eps} \\
\end{tabular}
\end{center}
\caption{Contact configuration}
\label{fig_physics_contact}
\end{figure}

Springhead�ō̗p���Ă���ڐG���f���ɂ��Đ������܂��D
��\ref{sec_physics_scene}�߂ŏq�ׂ��悤�ɁC\texttt{PHSceneIf::Step}�ɂ���ăV�~�����[�V������1�X�e�b�v�i�߂�ƁC
���߂Ɍ`��̌�������ƐڐG�S���̐������s���܂��D
���������̌`��̌����f�ʂƁC�ڐG�S���̊֌W�ɂ���Fig.\,\ref{fig_physics_contact}�Ɏ����܂��D
�}�ł͊ȒP�̂��߂ɓ񎟌��ŕ`���Ă��܂����C���ۂɂ͐ڐG�f�ʂ�\�����p�`�̊e���_�ɐڐG�S��������܂��D
�ڐG�S�������̍S���Ɠ��l�Ƀ\�P�b�g�ƃv���O�ō\������܂��D
����ŁC���̍S���Ƃ͈Ⴂ�ڐG�S���͌�������A���S���Y���ɂ���ē��I�ɐ����E�j������܂��D
���̂��߁C�ڐG���������̂̂ǂ���Ƀ\�P�b�g���邢�̓v���O�����t�����邩�͏󋵈ˑ��ł���C�O������I�����邱�Ƃ͂ł��܂���D

�v���O����у\�P�b�g�̌����͎��̂悤�ɂ��Č��܂�܂��D
�܂��Cx���͐ڐG�@���ƕ��s�Ɍ����܂��D�������ǂ��炪���̌������͏󋵈ˑ��ł��D
���ɁCy���͐ڐG�_�ɂ������̍��̂̑��Α��x�x�N�g����ڐG�f�ʂ֓��e���������Ɍ����܂��D
�Ō��z����x�Cy���ɒ�������悤�Ɍ��܂�܂��D

�ȉ��ł͊e�ڐG�S�����ۂ������ɂ��ċ�̓I�ɏq�ׂ܂��D
�܂��C�@�������̐i�����x�̑召�ɉ����ďՓ˃��f���ƐÓI�ڐG���f���̂����ꂩ���I������܂��D
\begin{align*}
v^\mathrm{x} < -V^\mathrm{th}   \;\; &\Rightarrow \;\; \text{�Փ˃��f��} \\
v^\mathrm{x} \ge -V^\mathrm{th} \;\; &\Rightarrow \;\; \text{�ÓI�ڐG���f��}
\end{align*}
������$v^\mathrm{x}$�̓\�P�b�g���猩���v���O�̑��Α��x��x���i�ڐG�@���j�����ŁC�߂Â����������𕉂Ƃ��܂��D
�܂��C$V^\mathrm{th}$�͏Փ˃��f���֐؂�ւ��ՊE���x�ł��D

�Փ˃��f���ł́C1�X�e�b�v��̑��Α��x${v^\mathrm{x}}'$�����˕Ԃ�W��$e$�ɂ��ƂÂ��Č��܂�C����𖞂����悤�ȐڐG�͂��v�Z����܂��D
\begin{align}
{v^\mathrm{x}}' = - e \, v^\mathrm{x}
\end{align}
�����ŁC���˕Ԃ�W���͏Փ˂���`��̕����l�ɒ�`���ꂽ���˕Ԃ�W���̕��ϒl�ł��D
%�e�`��̒��˕Ԃ�W���́C\texttt{CDShapeDesc::e}���C\texttt{CDShapeIf::SetElasticity}��p���Đݒ肵�܂�
%�i��\ref{sec_collision_material}�ߎQ�Ɓj�D

�ÓI�ڐG���f���ł́C�`�󓯎m�̐i���[�x$d$��1�X�e�b�v�ŏ���̊����Ō�������悤�ȐڐG�͂����߂܂��D
�܂�C1�X�e�b�v��̐i���[�x��$d'$�Ƃ����
\begin{align}
d' = d - \gamma \mathrm{max}(d - d^\mathrm{tol}, 0)
\end{align}
�ƂȂ�܂��D
������$\gamma$�͐ڐG�S���̌덷�C�����ł��D
�܂��C$d^\mathrm{tol}$�͋��e�i���[�x�ł��D

�Ō�ɁC�ڐG�͂��������ׂ������ɂ��ďq�ׂ܂��D
�܂��C�@�������ɂ͔����͂̂ݍ�p���邱�Ƃ���C�ڐG�͂�x������$f^\mathrm{x}$�ɂ�
\begin{align*}
f^\mathrm{x} \ge 0
\end{align*}
���ۂ����܂��D
����ŐڐG�͂�y������$f^\mathrm{y}$�Cz������$f^\mathrm{z}$�͖��C�͂�\���܂��D
���C�͂Ɋւ��ẮC���̌����̑��Α��x�ɂ��ƂÂ��Î~���C�������C�������肳��C����ɉ����čő喀�C�͂̐��񂪉ۂ���܂��D
\begin{align*}
-\mu_0 f^\mathrm{x} \le &f^\mathrm{y} \le \mu_0 f^\mathrm{x} & & \text{if} \; -V^\mathrm{f} \le v^\mathrm{y} \le V^\mathrm{f},\\
 \mu   f^\mathrm{x} \le &f^\mathrm{y} \le \mu   f^\mathrm{x} & & \text{otherwise}
\end{align*}
�����ŁC�Î~���C�W��$\mu_0$����ѓ����C�W��$\mu$�͒��˕Ԃ�W���Ɠ��l�Ɋe�`��̕����l�̕��ϒl���p�����܂��D
�܂��C$V^\mathrm{f}$�͐Î~���C�Ɠ����C���؂�ւ��ՊE���x�ł��D
z�������ɂ��Ă����l�̐��񂪉ۂ���܂��D

�ڐG���f���̊֌W����C���^�t�F�[�X�ɂ͈ȉ�������܂��D
\begin{center}
\begin{longtable}{p{.1\hsize}p{.5\hsize}p{.4\hsize}}
\multicolumn{3}{l}{\texttt{CDShapeIf}}						\\ \midrule
\texttt{void}	& \texttt{SetElasticity(float e)}       & ���˕Ԃ�W����ݒ� \\
\texttt{float}  & \texttt{GetElasticity()}              & ���˕Ԃ�W�����擾 \\
\texttt{void}   & \texttt{SetStaticFriction(float mu0)} & �Ö��C�W����ݒ� \\
\texttt{float}  & \texttt{GetStaticFriction()}          & �Ö��C�W�����擾 \\
\texttt{void}   & \texttt{SetDynamicFriction(float mu)} & �����C�W����ݒ� \\
\texttt{float}  & \texttt{GetDynamicFriction()}         & �����C�W�����擾
\end{longtable}
\end{center}

\begin{center}
\begin{longtable}{p{.1\hsize}p{.5\hsize}p{.4\hsize}}
\multicolumn{3}{l}{\texttt{PHSceneIf}}						\\ \midrule
\texttt{void}	& \texttt{SetContactTolerance(double tol)} & ���e�����[�x��ݒ� \\
\texttt{double} & \texttt{GetContactTolerance()}           & ���e�����[�x���擾 \\
\texttt{void}   & \texttt{SetImpactThreshold(double vth)}  & �ŏ��Փˑ��x��ݒ� \\
\texttt{double} & \texttt{GetImpactThreshold()}            & �ŏ��Փˑ��x���擾 \\
\texttt{void}   & \texttt{SetFrictionThreshold(double vf)} & �ŏ������C���x��ݒ� \\
\texttt{double} & \texttt{GetFrictionThreshold()}          & �ŏ������C���x���擾
\end{longtable}
\end{center}

\noindent\textbf{���l}
\begin{itemize}
\item �ڐG�f�ʂ̌����ɂ��ẮC�`�󓯎m�̐i�����x�����ƂɌ��肵�܂����C�����ł͏ڂ����q�ׂ܂���D
\item ���C�͂Ɋւ��Ă�y���Cz�����ʂɈ����܂����C���ۂ̖��C�͂�y������z�����̍��͂Ƃ��ė^�����܂��̂ŁC
���͂��ő喀�C�͂𒴉߂���\��������܂��D���̂悤��Springhead�̖��C���f���͂����܂ŋߎ��I�Ȃ��̂ł��̂�
���ӂ��ĉ������D
\end{itemize}

\subsection*{�ڐG�͂̎擾}

����̍��̂ɍ�p����ڐG�͂𒼐ڎ擾���邽�߂̃C���^�t�F�[�X�͗p�ӂ���Ă��܂���D
���̂��߁C���[�U�T�C�h�ł�����x�̌v�Z���s���K�v������܂��D
�ȉ��ɁC���鍄�̂ɍ�p����ڐG�͂̍��͂����߂��������܂��D

\begin{sourcecode}
// given PHSceneIf* scene
// given PHSolidIf* solid

Vec3d fsum;    //< sum of contact forces applied to "solid"
Vec3d tsum;    //< sum of contact torques applied to "solid"

int N = scene->NContacts();
Vec3d f, t;
Posed pose;

for(int i = 0; i < N; i++){
    PHContactPointIf* con = scene->GetContact(i);
    con->GetConstraintForce(f, t);

    if(con->GetSocketSolid() == solid){
        con->GetSocketPose(pose);
        fsum -= pose.Ori() * f;
        tsum -= pose.Pos() % pose.Ori() * f;
    }
    if(con->GetPlugSolid() == solid){
        con->GetPlugPose(pose);
        fsum += pose.Ori() * f;
        tsum += pose.Pos() % pose.Ori() * f;
    }
}
\end{sourcecode}
�܂��C�V�[�����̐ڐG�S���̐���\texttt{PHSceneIf::NConstacts}�Ŏ擾���C
\texttt{for}���[�v����$i$�Ԗڂ̐ڐG�S����\texttt{PHSceneIf::GetContact}�Ŏ擾���܂��D
����\texttt{PHConstraintIf::GetConstraintForce}�ŐڐG�͂̕��i��\texttt{f}�ƃ��[�����g\texttt{t}���擾���܂����C
�ڐG�S���̏ꍇ���[�����g��$0$�ł��̂ŗp���܂���D
�܂��C������S���͂̓\�P�b�g/�v���O���W�n�ŕ\�������̂ŁC��p�_�̓\�P�b�g/�v���O���W�n�̌��_�ł��D
������l�����č��̂ɍ�p����͂ƃ��[�����g�֕ϊ����C���͂ɑ������킹�Ă����܂��D
���̂��\�P�b�g���ł���ꍇ�͍�p�E����p���l�����ĕ����𔽓]���邱�Ƃɒ��ӂ��ĉ������D


\subsection*{�ڐG�͌v�Z�̗L��/�����̐؂�ւ�}

�����̃A�v���P�[�V�����ł́C���ׂĂ̍��̂̑g�ݍ��킹�Ɋւ��ĐڐG����舵���K�v�͂���܂���D
���̂悤�ȏꍇ�͕K�v�ȍ��̂̑΂Ɋւ��Ă̂ݐڐG��L�������邱�ƂŌv�Z�R�X�g���팸�ł��܂��D
Springhead�ł́C���̂̑g�ݍ��킹���Ɍ������肨��ѐڐG�͌v�Z���s������؂�ւ��邱�Ƃ��ł��܂��D
����ɂ�\texttt{PHSceneIf::SetContactMode}��p���܂��D

\begin{center}
\begin{longtable}{p{.1\hsize}p{.9\hsize}}
\multicolumn{2}{l}{\texttt{PHSceneIf}}						\\ \midrule
\texttt{void}	& \texttt{SetContactMode(PHSolidIf* lhs, PHSolidIf* rhs, int mode)} \\
\texttt{void}   & \texttt{SetContactMode(PHSolidIf** group, size\_t length, int mode)} \\
\texttt{void}   & \texttt{SetContactMode(PHSolidIf* solid, int mode)} \\
\texttt{void}   & \texttt{SetContactMode(int mode)}
\end{longtable}
\end{center}

��Ԗڂ͍���\texttt{lhs}��\texttt{rhs}�̑΂Ɋւ��ă��[�h��ݒ肵�܂��D
��Ԗڂ͔z��\texttt{[group, group + length)}�Ɋi�[���ꂽ���̂̑S�g�ݍ��킹�Ɋւ��Đݒ肵�܂��D
�O�Ԗڂ͍���\texttt{solid}�Ƒ��̑S���̂Ƃ̑g�ݍ��킹�Ɋւ��Đݒ肵�܂��D
�l�Ԗڂ̓V�[�����̂��ׂĂ̍��̂̑g�ݍ��킹�Ɋւ��Đݒ肵�܂��D

�ݒ�\�ȃ��[�h�͈ȉ��̓��̈�ł��D
\begin{center}
\begin{longtable}{p{.3\hsize}p{.7\hsize}}
\multicolumn{2}{l}{\texttt{PHSceneDesc::ContactMode}} \\ \midrule
\texttt{MODE\_NONE}	   & �������肨��ѐڐG�͌v�Z���s��Ȃ� \\
\texttt{MODE\_LCP}     & ����������s���C�S���͌v�Z�@��p���� \\
\texttt{MODE\_PENALTY} & ����������s���C�y�i���e�B���͖@��p���� \\
\end{longtable}
\end{center}
�f�t�H���g�ł͂��ׂĂ̍��̑΂Ɋւ���\texttt{MODE\_LCP}���I������Ă��܂��D
��Ƃ��āC���ʂƂ̐ڐG�ȊO�����ׂăI�t�ɂ���ɂ�
\begin{sourcecode}
// given PHSolidIf* floor

scene->SetContactMode(PHSceneDesc::MODE_NONE);
scene->SetContactMode(floor, PHSceneDesc::MODE_LCP);
\end{sourcecode}
�Ƃ��܂��D

\section{�֐ߍ��W�n�V�~�����[�V����}

\index{���񂹂��Ђ傤����@�֐ߍ��W�n}
T.B.D.


\section{�M�A}

\index{����@�M�A}
T.B.D.

\section{�����A���S���Y���̐ݒ�}
\label{sec_physics_engine}

�ȉ��ł͕����V�~�����[�V�����̓����ŗp�����Ă���A���S���Y���̏ڍׂȐݒ荀�ڂɂ��Đ������܂��D

\subsection*{�S���͌v�Z�G���W��}

�S���͌v�Z�G���W���́C�֐߂�ڐG�Ȃǂ̍S���𖞑����邽�߂̍S���͂̌v�Z���s���܂��D
�S���͌v�Z�G���W���̃N���X��\texttt{PHConstraintEngineIf}�ŁC������擾����ɂ͈ȉ��̊֐���p���܂��D


\texttt{PHConstraintEngineIf}�̃C���^�t�F�[�X���ȉ��Ɏ����܂��D

\begin{center}
\begin{longtable}{p{.12\hsize}p{.45\hsize}p{.33\hsize}}
\multicolumn{3}{l}{\texttt{PHConstraintEngineIf}}			\\ \midrule
\texttt{void}	& \texttt{SetVelCorrectionRate(double)}		& �֐ߍS���̌덷�C������ݒ� \\
\texttt{double} & \texttt{GetVelCorrectionRate()}			& �֐ߍS���̌덷�C�������擾 \\
\texttt{void}	& \texttt{SetContactCorrectionRate(double)}	& �ڐG�S���̌덷�C������ݒ� \\
\texttt{double} & \texttt{GetContactCorrectionRate()}		& �ڐG�S���̌덷�C�������擾 \\
\end{longtable}
\end{center}

�덷�C�����Ƃ́C1�X�e�b�v�ōS���덷�ǂ̒��x�C�����邩�������䗦�ŁC�ʏ�$[0, 1]$�̒l��ݒ肵�܂��D
�덷�C������$1$�ɂ���ƁC1�X�e�b�v�ōS���덷��$0$�ɂ���悤�ȍS���͂��v�Z����܂����C���U���ۂȂǂ̃V�~�����[�V�����̕s���艻�������X��������܂��D
�t�ɏC�����������ڂɐݒ肷��΃V�~�����[�V�����͈��艻���܂����C���덷�����債�܂��D

�S���͌v�Z�G���W���́C�����Ŕ����^�̃A���S���Y���ōS���͂��v�Z���܂��D
�A���S���Y���̔����񐔂�\texttt{PHSceneIf::SetNumIteration}�Őݒ肵�܂��i��\ref{sec_physics_scene}�ߎQ�Ɓj�D


\texttt{PHSceneIf::SetContactTolerance}�Őݒ�\�ł��D

\texttt{PHConstraintEngineIf::SetContactCorrectionRate}�Őݒ�\�ł�
�i��\ref{sec_physics_engine}�ߎQ�Ɓj�D
