packages/pyglGA/scripts/basicCharacterApp.py
def GLMTests():
    """
    test glm vec, mat and quat data structures
    """
    t = glm.vec4(10., -5., 6.1, 1.)
    t0 = t1 = t2 = t3 = None
    origin = glm.vec4(0., 0., 0., 1.)
    point = glm.vec4(1., 2., 3., 1.)
    axisRaw = glm.quat(10., 1., 1., 1.)
    axis = glm.normalize(axisRaw)
    q1 = glm.quat(1., 1., 1., 1.)
    q2 = glm.quat(1.0, glm.vec3(1., 0., 0.))
    transMat = glm.mat4(1.0)
    rotMat = glm.mat4(1.0)
    mat1 = glm.mat4(1., 0., 0., 0.,
                    0., 1., 0., 0.,
                    0., 0., 1., 0.,
                    -10., 10., 10., 1.)
    # access translation vector, column major matrix
    print(mat1)
    print('x:',mat1[3, 0])
    print('y:', mat1[3, 1])
    print('z:', mat1[3, 2])

    # each row is a column
    # so we write it as a Transpose here
    mat2 = glm.mat4(glm.vec4(1., 0., 0., 10.),
                    glm.vec4(0., 1., 0., 10.),
                    glm.vec4(0., 0., 1., 10.),
                    glm.vec4(0., 0., 0., 1.))  # wrongly specified as row major

    identity = glm.mat4(1.0)

    print("\n identity mat4: \n", identity)
    print("\n transMat mat4: \n", transMat)
    print("\n rotMat mat4: \n", rotMat)
    print("\n t : \n", t)
    print("\n point : \n", point)
    print("\n mat1 mat4: \n", mat1)
    print("\n mat2 mat4: \n", mat2)
    print("\n axis : \n", axis)
    print("\n q2 : \n", q2)

    t0 = mat1[0]
    t1 = mat1[1]
    t2 = mat1[2]
    t3 = mat1[3]
    elem03 = mat1[3][0]
    print('t0, t1, t2, t3')
    print('elem03: ', elem03)

    print('t to_string: ', t)
    print('mat1 to_string: ', mat1)

    q1 = glm.conjugate(axis)
    print("conjugate-axis", q1)
    q1 = glm.inverse(axis)
    print("inverse-axis", q1)
    qMat = glm.mat4(1.0)
    qMat = glm.mat4_cast(axis)
    print("axis: q -> Mat", qMat)
    q = glm.quat_cast(qMat)
    print("q: mat -> quat", q)
    q2 = glm.rotate(q, 90., glm.vec3(1., 0., 0.))
    print("rotated q by 90 in X: ", q2)
    gInt0 = gInt = gInt1 = glm.quat(1., 1., 1., 1.)
    gInt0 = glm.slerp(q, q2, 0.)
    gInt = glm.slerp(q, q2, 0.5)
    gInt1 = glm.slerp(q, q2, 1.)
    print("interpolated gInt: [q to q2 by 0.5:", gInt)
    print("interpolated gInt: [q to q2 by 0.0:", gInt0)
    print("interpolated gInt: [q to q2 by 1.0:", gInt1)

    print('************ POINT QUATERNION INTERPOLATION EXPERIMENT **************')
    p = glm.quat(0., 0., 1., 1.)
    Q = glm.angleAxis(90., glm.vec3(0., 1., 0.))
    angle = glm.angle(Q)
    axisOfRotation = glm.axis(Q)
    print('verified quat Q angle is:', angle, 'and axis:', axisOfRotation)
    Q1 = glm.conjugate(Q)
    p2 = Q * p * Q1
    print("rotated P by 90 Y degrees:", p2)
    qIntExp = glm.slerp(p, p2, 0.5)
    print("interpolated gIntExp: [p to p2 by 0.5:", qIntExp)
    print('********* END POINT QUATERNION INTERPOLATION EXPERIMENT **********')

    transMat = glm.translate(glm.mat4(1.0), glm.vec3(10.,20.,30.))
    print("transMat", transMat)
    print(transMat)
    print('x:', transMat[3, 0])
    print('y:', transMat[3, 1])
    print('z:', transMat[3, 2])

    t = t * point
    t = transMat * glm.vec4(1.0)
    origin = mat1 * origin
    print("transMat", transMat)
    print("t", t)
    print("origin", origin)
    origin = mat2 * glm.vec4(0.0, 0.0, 0.0, 1.0)
    print("origin", origin)
    origin = glm.transpose(mat2) * glm.vec4(0., 0., 0., 1.)
    print("origin", origin)
    invMat = glm.mat4(1.0)
    invMat = glm.inverse(mat1)
    print("invMat", invMat)
    Rotate = glm.vec3(1., 1., 1.)
    Translate = glm.vec3(1., 1., 1.)
    ViewTranslate = glm.translate(glm.mat4(1.0), Translate)
    ViewRotateX = glm.rotate(ViewTranslate, Rotate.y, glm.vec3(-1., 0., 0.))

    print('origin.x: ', origin.x)

    print('*********************   Dual Quaternion tests *********************')
    print("NOT SUPPORTED IN pyGLM (YET)!")

    print('*********************   END OF GLM TESTS  *********************')

    test glm vec, mat and quat data structures
    
test glm vec, mat and quat data structures
test glm vec mat and quat data structures
def GLMTests():
    t = glm.vec4(10., -5., 6.1, 1.)
    t0 = t1 = t2 = t3 = None
    origin = glm.vec4(0., 0., 0., 1.)
    point = glm.vec4(1., 2., 3., 1.)
    axisRaw = glm.quat(10., 1., 1., 1.)
    axis = glm.normalize(axisRaw)
    q1 = glm.quat(1., 1., 1., 1.)
    q2 = glm.quat(1.0, glm.vec3(1., 0., 0.))
    transMat = glm.mat4(1.0)
    rotMat = glm.mat4(1.0)
    mat1 = glm.mat4(1., 0., 0., 0.,
                    0., 1., 0., 0.,
                    0., 0., 1., 0.,
                    -10., 10., 10., 1.)
    print(mat1)
    print('x:',mat1[3, 0])
    print('y:', mat1[3, 1])
    print('z:', mat1[3, 2])
    mat2 = glm.mat4(glm.vec4(1., 0., 0., 10.),
                    glm.vec4(0., 1., 0., 10.),
                    glm.vec4(0., 0., 1., 10.),
                    glm.vec4(0., 0., 0., 1.))  
    identity = glm.mat4(1.0)
    print("\n identity mat4: \n", identity)
    print("\n transMat mat4: \n", transMat)
    print("\n rotMat mat4: \n", rotMat)
    print("\n t : \n", t)
    print("\n point : \n", point)
    print("\n mat1 mat4: \n", mat1)
    print("\n mat2 mat4: \n", mat2)
    print("\n axis : \n", axis)
    print("\n q2 : \n", q2)
    t0 = mat1[0]
    t1 = mat1[1]
    t2 = mat1[2]
    t3 = mat1[3]
    elem03 = mat1[3][0]
    print('t0, t1, t2, t3')
    print('elem03: ', elem03)
    print('t to_string: ', t)
    print('mat1 to_string: ', mat1)
    q1 = glm.conjugate(axis)
    print("conjugate-axis", q1)
    q1 = glm.inverse(axis)
    print("inverse-axis", q1)
    qMat = glm.mat4(1.0)
    qMat = glm.mat4_cast(axis)
    print("axis: q -> Mat", qMat)
    q = glm.quat_cast(qMat)
    print("q: mat -> quat", q)
    q2 = glm.rotate(q, 90., glm.vec3(1., 0., 0.))
    print("rotated q by 90 in X: ", q2)
    gInt0 = gInt = gInt1 = glm.quat(1., 1., 1., 1.)
    gInt0 = glm.slerp(q, q2, 0.)
    gInt = glm.slerp(q, q2, 0.5)
    gInt1 = glm.slerp(q, q2, 1.)
    print("interpolated gInt: [q to q2 by 0.5:", gInt)
    print("interpolated gInt: [q to q2 by 0.0:", gInt0)
    print("interpolated gInt: [q to q2 by 1.0:", gInt1)
    print('************ POINT QUATERNION INTERPOLATION EXPERIMENT **************')
    p = glm.quat(0., 0., 1., 1.)
    Q = glm.angleAxis(90., glm.vec3(0., 1., 0.))
    angle = glm.angle(Q)
    axisOfRotation = glm.axis(Q)
    print('verified quat Q angle is:', angle, 'and axis:', axisOfRotation)
    Q1 = glm.conjugate(Q)
    p2 = Q * p * Q1
    print("rotated P by 90 Y degrees:", p2)
    qIntExp = glm.slerp(p, p2, 0.5)
    print("interpolated gIntExp: [p to p2 by 0.5:", qIntExp)
    print('********* END POINT QUATERNION INTERPOLATION EXPERIMENT **********')
    transMat = glm.translate(glm.mat4(1.0), glm.vec3(10.,20.,30.))
    print("transMat", transMat)
    print(transMat)
    print('x:', transMat[3, 0])
    print('y:', transMat[3, 1])
    print('z:', transMat[3, 2])
    t = t * point
    t = transMat * glm.vec4(1.0)
    origin = mat1 * origin
    print("transMat", transMat)
    print("t", t)
    print("origin", origin)
    origin = mat2 * glm.vec4(0.0, 0.0, 0.0, 1.0)
    print("origin", origin)
    origin = glm.transpose(mat2) * glm.vec4(0., 0., 0., 1.)
    print("origin", origin)
    invMat = glm.mat4(1.0)
    invMat = glm.inverse(mat1)
    print("invMat", invMat)
    Rotate = glm.vec3(1., 1., 1.)
    Translate = glm.vec3(1., 1., 1.)
    ViewTranslate = glm.translate(glm.mat4(1.0), Translate)
    ViewRotateX = glm.rotate(ViewTranslate, Rotate.y, glm.vec3(-1., 0., 0.))
    print('origin.x: ', origin.x)
    print('*********************   Dual Quaternion tests *********************')
    print("NOT SUPPORTED IN pyGLM (YET)!")
    print('*********************   END OF GLM TESTS  *********************')
def GLMTests ( ) : t = glm . vec4 ( 10. , - 5. , 6.1 , 1. ) t0 = t1 = t2 = t3 = None origin = glm . vec4 ( 0. , 0. , 0. , 1. ) point = glm . vec4 ( 1. , 2. , 3. , 1. ) axisRaw = glm . quat ( 10. , 1. , 1. , 1. ) axis = glm . normalize ( axisRaw ) q1 = glm . quat ( 1. , 1. , 1. , 1. ) q2 = glm . quat ( 1.0 , glm . vec3 ( 1. , 0. , 0. ) ) transMat = glm . mat4 ( 1.0 ) rotMat = glm . mat4 ( 1.0 ) mat1 = glm . mat4 ( 1. , 0. , 0. , 0. , 0. , 1. , 0. , 0. , 0. , 0. , 1. , 0. , - 10. , 10. , 10. , 1. ) print ( mat1 ) print ( 'x:' , mat1 [ 3 , 0 ] ) print ( 'y:' , mat1 [ 3 , 1 ] ) print ( 'z:' , mat1 [ 3 , 2 ] ) mat2 = glm . mat4 ( glm . vec4 ( 1. , 0. , 0. , 10. ) , glm . vec4 ( 0. , 1. , 0. , 10. ) , glm . vec4 ( 0. , 0. , 1. , 10. ) , glm . vec4 ( 0. , 0. , 0. , 1. ) ) identity = glm . mat4 ( 1.0 ) print ( "\n identity mat4: \n" , identity ) print ( "\n transMat mat4: \n" , transMat ) print ( "\n rotMat mat4: \n" , rotMat ) print ( "\n t : \n" , t ) print ( "\n point : \n" , point ) print ( "\n mat1 mat4: \n" , mat1 ) print ( "\n mat2 mat4: \n" , mat2 ) print ( "\n axis : \n" , axis ) print ( "\n q2 : \n" , q2 ) t0 = mat1 [ 0 ] t1 = mat1 [ 1 ] t2 = mat1 [ 2 ] t3 = mat1 [ 3 ] elem03 = mat1 [ 3 ] [ 0 ] print ( 't0, t1, t2, t3' ) print ( 'elem03: ' , elem03 ) print ( 't to_string: ' , t ) print ( 'mat1 to_string: ' , mat1 ) q1 = glm . conjugate ( axis ) print ( "conjugate-axis" , q1 ) q1 = glm . inverse ( axis ) print ( "inverse-axis" , q1 ) qMat = glm . mat4 ( 1.0 ) qMat = glm . mat4_cast ( axis ) print ( "axis: q -> Mat" , qMat ) q = glm . quat_cast ( qMat ) print ( "q: mat -> quat" , q ) q2 = glm . rotate ( q , 90. , glm . vec3 ( 1. , 0. , 0. ) ) print ( "rotated q by 90 in X: " , q2 ) gInt0 = gInt = gInt1 = glm . quat ( 1. , 1. , 1. , 1. ) gInt0 = glm . slerp ( q , q2 , 0. ) gInt = glm . slerp ( q , q2 , 0.5 ) gInt1 = glm . slerp ( q , q2 , 1. ) print ( "interpolated gInt: [q to q2 by 0.5:" , gInt ) print ( "interpolated gInt: [q to q2 by 0.0:" , gInt0 ) print ( "interpolated gInt: [q to q2 by 1.0:" , gInt1 ) print ( '************ POINT QUATERNION INTERPOLATION EXPERIMENT **************' ) p = glm . quat ( 0. , 0. , 1. , 1. ) Q = glm . angleAxis ( 90. , glm . vec3 ( 0. , 1. , 0. ) ) angle = glm . angle ( Q ) axisOfRotation = glm . axis ( Q ) print ( 'verified quat Q angle is:' , angle , 'and axis:' , axisOfRotation ) Q1 = glm . conjugate ( Q ) p2 = Q * p * Q1 print ( "rotated P by 90 Y degrees:" , p2 ) qIntExp = glm . slerp ( p , p2 , 0.5 ) print ( "interpolated gIntExp: [p to p2 by 0.5:" , qIntExp ) print ( '********* END POINT QUATERNION INTERPOLATION EXPERIMENT **********' ) transMat = glm . translate ( glm . mat4 ( 1.0 ) , glm . vec3 ( 10. , 20. , 30. ) ) print ( "transMat" , transMat ) print ( transMat ) print ( 'x:' , transMat [ 3 , 0 ] ) print ( 'y:' , transMat [ 3 , 1 ] ) print ( 'z:' , transMat [ 3 , 2 ] ) t = t * point t = transMat * glm . vec4 ( 1.0 ) origin = mat1 * origin print ( "transMat" , transMat ) print ( "t" , t ) print ( "origin" , origin ) origin = mat2 * glm . vec4 ( 0.0 , 0.0 , 0.0 , 1.0 ) print ( "origin" , origin ) origin = glm . transpose ( mat2 ) * glm . vec4 ( 0. , 0. , 0. , 1. ) print ( "origin" , origin ) invMat = glm . mat4 ( 1.0 ) invMat = glm . inverse ( mat1 ) print ( "invMat" , invMat ) Rotate = glm . vec3 ( 1. , 1. , 1. ) Translate = glm . vec3 ( 1. , 1. , 1. ) ViewTranslate = glm . translate ( glm . mat4 ( 1.0 ) , Translate ) ViewRotateX = glm . rotate ( ViewTranslate , Rotate . y , glm . vec3 ( - 1. , 0. , 0. ) ) print ( 'origin.x: ' , origin . x ) print ( '*********************   Dual Quaternion tests *********************' ) print ( "NOT SUPPORTED IN pyGLM (YET)!" ) print ( '*********************   END OF GLM TESTS  *********************' )
test glm vec, mat and quat data structures
test glm vec mat and quat data structures
"""
    test glm vec, mat and quat data structures
    """ # access translation vector, column major matrix # each row is a column # so we write it as a Transpose here # wrongly specified as row major