Jump to content
  • Advertisement

jalex

Member
  • Content Count

    4
  • Joined

  • Last visited

Community Reputation

0 Neutral

About jalex

  • Rank
    Newbie

Personal Information

  • Interests
    Programming

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. jalex

    3D Rigidbody Simulation

    Great reference! Thank you.
  2. jalex

    3D Rigidbody Simulation

    I understand what you are saying, but if you do the math you will see that the angle drifts away with order O(ω*dt) which is the same error order as an Euler step. So if that is ok with the simulation and any long term numerical artifacts, that is ok. But for some cases a higher order integrator is needed (like Runge Kutta) and then this method fails. In the attached paper there is an example in the end. Starting with a quaternion from the rotation about the \( x \)-axis, apply some rotational velocity about another axis, like \( z \). Do that with many small Euler steps, and you will get the same answer as the method I propose with 1 step. quaternion_step.pdf
  3. jalex

    3D Rigidbody Simulation

    This integration scheme is very common for quaternions, and quite wrong as the resulting quaternion `q_next` after a finite time step `dt` isn't a rotation anymore (with error O(dt)) Try the following: Convert \( \vec{\omega} \) into a rotation, but converting into an angle \( \theta = dt * \| \vec{\omega} \| \) and axis \( \hat{z} = \vec{\omega} / \| \vec{\omega} \| \). Then define a new quaternion `q_rot` using the axis/angle definition and perform the rotation step $$ q_{\rm next} \Rightarrow q_{\rm rot} q $$ In term of the vector+scalar components of ther quaternion the above is: $$ \begin{pmatrix}\vec q_{\rm next}\\ q_{\next} \end{pmatrix} \Rightarrow\begin{pmatrix}\left(\tfrac{1}{\omega}\sin\frac{dt\,\omega}{2}\right)\vec\omega\\ \cos\frac{dt\,\omega}{2} \end{pmatrix}\,\begin{pmatrix}\vec q\\ q \end{pmatrix} $$ This integration scheme is very common for quaternions, and quite wrong as the resulting quaternion `q_next` after a finite time step `dt` isn't a rotation anymore (with error O(dt)) Try the following: Convert \( \vec{\omega} \) into a rotation, but converting into an angle \( \theta = dt * \| \vec{\omega} \| \) and axis \( \hat{z} = \vec{\omega} / \| \vec{\omega} \| \). Then define a new quaternion `q_rot` using the axis/angle definition and perform the rotation step $$ q_{\rm next} \Rightarrow q_{\rm rot} q $$ In term of the vector+scalar components of ther quaternion the above is: $$ \begin{pmatrix}\vec q_{\rm next}\\ q_{\rm next} \end{pmatrix} \Rightarrow\begin{pmatrix}\left(\tfrac{1}{\omega}\sin\frac{\theta}{2}\right)\vec{z}\\ \cos\frac{\theta}{2} \end{pmatrix}\,\begin{pmatrix}\vec q\\ q \end{pmatrix} $$
  4. jalex

    Torque Force Mass Question

    If you are using wrenches for momenta or forces, then you need to use the spatial inertia matrix to convert motion twists into wrenches, The 6×6 spatial momentum of a particle of mass \( m \) located at \( \boldsymbol{c} \) is defined by the following block matrix $$ \mathbf{I} = \begin{bmatrix} m & -m [\boldsymbol{c}\times] \\ m [\boldsymbol{c}\times] & - m [\boldsymbol{c}\times][\boldsymbol{c}\times] \end{bmatrix} $$ Here \( [\boldsymbol{c}\times] \) is the [3×3 matrix representation of the cross product](https://en.wikipedia.org/wiki/Cross_product#Conversion_to_matrix_multiplication). Example: I am using a momentum wrench because the math is easier to demonstrate, but the same rules apply to forces (since they are also wrenches). But particle accelerations are _not_ twists, You have to convert them to spatial accelerations to use them. The velocity twist of a particle is $$ \mathbf{v} = \begin{bmatrix}\boldsymbol{v}_{C}+\boldsymbol{c}\times\boldsymbol{\omega}\\ \boldsymbol{\omega} \end{bmatrix} $$ as seen by the origin. Using the spatial inertia from above the momentum is $$ \mathbf{p}=\mathbf{I}\mathbf{v} $$ which expands out to $$ \begin{bmatrix}\boldsymbol{p}\\ \boldsymbol{c}\times\boldsymbol{p} \end{bmatrix}=\begin{bmatrix}m & -m[\boldsymbol{c}\times]\\ m[\boldsymbol{c}\times] & -m[\boldsymbol{c}\times][\boldsymbol{c}\times] \end{bmatrix}\begin{bmatrix}\boldsymbol{v}_{C}+\boldsymbol{c}\times\boldsymbol{\omega}\\ \boldsymbol{\omega} \end{bmatrix} $$ carry out the multiplication $$\begin{bmatrix}m\boldsymbol{v}_{C}+m\left(\boldsymbol{c}\times\boldsymbol{\omega}\right)-m\left(\boldsymbol{c}\times\boldsymbol{\omega}\right)\\ m\boldsymbol{c}\times\left(\boldsymbol{v}_{C}+\boldsymbol{c}\times\boldsymbol{\omega}\right)-m\boldsymbol{c}\times\left(\boldsymbol{c}\times\boldsymbol{\omega}\right) \end{bmatrix} = \begin{bmatrix}m\boldsymbol{v}_{C}\\ \boldsymbol{c}\times\left(m\boldsymbol{v}_{C}\right) \end{bmatrix}$$ The above confirms the known vector relationships of \( \boldsymbol{p} = m \boldsymbol{v}_C \) and \( \boldsymbol{L} = \boldsymbol{c} \times \boldsymbol{p} \)
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!