Example a/time_dependent_transformation: Time dependent transformation with quaternion

This example demostrates the use of quaternion in cmgui. Quaternion provides smooth and time dependent transformation. This example reads in two finite element field at different time steps and these two finite element fields describe the rotation and translation of an object. Field representing the 4x4 transformation matrix will be converted to a quaternion and then interpolation of the quaternion between each time step will be done with a technique called quaternion SLERP. The interpolated quaternion will then be converted back to a 4x4 matrix and can then be used to describe transformation of an object at different time. Created by Alan Wu, February 2008.

Screenshot of example a/time_dependent_transformation

The comfile run by this example is as follows:

# Example time_dependent_transformation
gfx create region cube;
gfx read nodes example cube region cube;

#dummy node with the transformation matrix stored in a FE_field
gfx read nodes example new_cube0 time 0 region cube;
gfx read nodes example new_cube1 time 50 region cube;
gfx read nodes example new_cube2 time 100 region cube;
gfx read nodes example new_cube3 time 150 region cube;
gfx read nodes example new_cube0 time 200 region cube;
gfx read elements example cube region cube;

gfx create material blue ambient 0.2 0.2 0.9 diffuse 0.2 0.2 0.9;
gfx modify g_element "/" point glyph axes_xyz general size "1.2*1.2*1.2" select_on material white selected_material default;
gfx modify g_element cube general clear;
gfx modify g_element cube lines coordinate coordinates material default;
gfx modify g_element cube node_points coordinate coordinates glyph point general size "1*1*1" centre 0,0,0 font default label cmiss_number select_on material red selected_material default_selected;
gfx modify g_element cube cylinders coordinate coordinates constant_radius 0.02 select_on material green selected_material default_selected;
gfx modify g_element cube surfaces coordinate coordinates select_on material silver selected_material default_selected render_shaded;

#Read in a finite element field which describe the matrix field and
#convert it to a quaternion computed_field
gfx define field cube/new_quaternion matrix_to_quaternion field transformation_matrix;
#apply quaternion slerp to linearly intepolated the rotation described
#by two quaternion field at two different time step
gfx define field cube/interpolated_quaternion quaternion_SLERP field new_quaternion node 2001;
#Convert the intepolated quaternion field back to a 4x4 transformation matrix
gfx define field cube/new_matrix quaternion_to_matrix field interpolated_quaternion;
#the following two commands add a translation to the new_matrix, the translation is also stored
#as a field in the dummy node
gfx define field cube/transformation_field add field new_matrix translation_field;
gfx define field cube/new_transformation_field nodal_lookup field transformation_field node 2001;

#set transformation of object cube with the time dependent transformation field
gfx set transformation name cube field new_transformation_field;
gfx create window;
gfx modify window 1 view parallel eye_point 2.565 -2.21865 1.41009 interest_point 0.5 0.5 0.5 up_vector -0.154359 0.206216 0.966255 view_angle 66.9472; near_clipping_plane 0.0353321 far_clipping_plane 12.6265 relative_viewport ndc_placement -1 1 2 2 viewport_coordinates 0 0 1 1;
gfx timekeeper default play speed 50;

Files used by this example are:

Name                                       Modified     Size

example_time_dependent_transformation.com 17-Mar-2014 2.6k COPYRIGHT 17-Mar-2014 504 cube.exelem 17-Mar-2014 3.4k cube.exnode 17-Mar-2014 413 new_cube0.exnode 17-Mar-2014 1.8k new_cube1.exnode 17-Mar-2014 1.8k new_cube2.exnode 17-Mar-2014 1.8k new_cube3.exnode 17-Mar-2014 1.8k

Download the entire example:

Name                                             Modified     Size

examples_a_time_dependent_transformation.tar.gz 09-Mar-2016 17k

Testing status by version:

StatusTestedReal time (s)
cmgui-wxFailureSun Mar 6 00:10:00 20163
last breakTue Feb 24 00:02:00 20153
cmgui-wx-debugFailureSun Mar 6 00:10:27 20162
last breakTue Feb 24 03:11:00 20152
cmgui-wx-debug-memorycheckFailureSun Mar 6 00:10:29 20163
last breakTue Feb 24 03:12:00 20152
cmgui-wx-debug-valgrindFailureSun Mar 6 00:53:17 201636
last breakSun Mar 6 00:52:00 201636
cmgui-wxFailureSun Mar 6 00:01:34 20160
last breakSun Mar 6 00:01:00 20160
cmgui-wx-debugFailureSun Mar 6 00:01:35 20160
last breakSun Mar 6 00:01:00 20160
cmgui-wx-debug-memorycheckFailureSun Mar 6 00:01:35 20160
last breakSun Mar 6 00:01:00 20160
cmgui-wx-debug-valgrindFailureSun Mar 6 00:03:27 20169
last breakSun Mar 6 00:03:00 20169

Testing status by file:

Html last generated: Wed Mar 9 16:02:53 2016

Input last modified: Wed Mar 9 15:49:40 2016

CMISS Help / Examples / a / time_dependent_transformation