Example a_backup/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_backup/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 20-Apr-2012 2.6k COPYRIGHT 19-Apr-2012 504 cube.exelem 20-Apr-2012 3.4k cube.exnode 20-Apr-2012 413 new_cube0.exnode 20-Apr-2012 1.8k new_cube1.exnode 20-Apr-2012 1.8k new_cube2.exnode 20-Apr-2012 1.8k new_cube3.exnode 20-Apr-2012 1.8k

Download the entire example:

Name                                                    Modified     Size

examples_a_backup_time_dependent_transformation.tar.gz 12-Aug-2014 17k

Testing status by version:

StatusTestedReal time (s)
cmgui-wxSuccessSun Mar 6 00:11:29 20162
cmgui-wx-debugSuccessSun Mar 6 00:13:24 20162
cmgui-wx-debug-memorycheckSuccessSun Mar 6 00:10:41 20162
cmgui-wx-debug-valgrindFailureSun Mar 6 00:51:33 201639
last breakSun Mar 6 00:50:00 201639
last successTue Feb 10 00:44:00 201540
cmgui-wxFailureSun Mar 6 00:01:38 20160
last breakSun Mar 6 00:01:00 20160
last successWed Jun 3 00:05:00 20150
cmgui-wx-debugFailureSun Mar 6 00:01:38 20160
last breakSun Mar 6 00:01:00 20160
last successWed Jun 3 00:05:00 20151
cmgui-wx-debug-memorycheckFailureSun Mar 6 00:01:38 20160
last breakSun Mar 6 00:01:00 20160
last successWed Jun 3 00:05:00 20151
cmgui-wx-debug-valgrindFailureSun Mar 6 00:03:14 20169
last breakSun Mar 6 00:03:00 20169
last successWed Jun 3 00:27:00 201531

Testing status by file:

Html last generated: Sun Mar 6 05:51:03 2016

Input last modified: Fri Apr 20 16:02:45 2012

CMISS Help / Examples / a_backup / time_dependent_transformation