Giter Site home page Giter Site logo

Comments (2)

EveCharbie avatar EveCharbie commented on August 28, 2024

code to be translated to c++ :

def matrix_calc(Q, seq):
    seq_num = np.zeros((3,))
    for i in range(3):
        if seq[i] == 'x':
            seq_num[i] = 0
        elif seq[i] == 'y':
            seq_num[i] = 1
        elif seq[i] == 'z':
            seq_num[i] = 2

    vect_units = np.zeros((3, 3))
    for i in range(3):
        vect_units[i, int(seq_num[i])] = 1

    Rot_mat_1 = biorbd.Rotation_fromEulerAngles(np.array([Q[0], 0, 0]), seq).to_array()
    Rot_mat_2 = biorbd.Rotation_fromEulerAngles(np.array([Q[0], Q[1], 0]), seq).to_array()

    matrix = np.zeros((3, 3,))
    matrix[:, 0] = np.eye(3) @ vect_units[0, :]
    matrix[:, 1] = Rot_mat_1 @ vect_units[1, :]
    matrix[:, 2] = Rot_mat_2 @ vect_units[2, :]
    return matrix

def Qdot_to_omega(Q, Qdot, seq):

    matrix = matrix_calc(Q, seq)
    omega = matrix @ Qdot

    return omega

def omega_to_Qdot(Q, omega, seq):

    matrix = np.linalg.inv(matrix_calc(Q, seq))
    Qdot = matrix @ omega

    return Qdot

from http://www.stengel.mycpanel.princeton.edu/Quaternions.pdf

from biorbd.

EveCharbie avatar EveCharbie commented on August 28, 2024

@fbailly could you confirm before I translate it since you implemented the 'xyz' sequence ?

from biorbd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.