demo.py
Go to the documentation of this file.
1 import pyquaternion
2 
3 
4 # Create a quaternion representing a rotation of +90 degrees about positive y axis.
5 my_quaternion = pyquaternion.Quaternion(axis=[0, 1, 0], degrees=90)
6 
7 my_vector = [0, 0, 4]
8 my_rotated_vector = my_quaternion.rotate(my_vector)
9 
10 print('\nBasic Rotation')
11 print('--------------')
12 print('My Vector: {}'.format(my_vector))
13 print('Performing rotation of {angle} deg about {axis}'.format(angle=my_quaternion.degrees, axis=my_quaternion.axis))
14 print('My Rotated Vector: {}'.format(my_rotated_vector))
15 
16 
17 # Create another quaternion representing no rotation at all
18 null_quaternion = pyquaternion.Quaternion(axis=[0, 1, 0], angle=0)
19 
20 print('\nInterpolated Rotation')
21 print('---------------------')
22 
23 # The following will create a sequence of 9 intermediate quaternion rotation objects
24 for q in pyquaternion.Quaternion.intermediates(null_quaternion, my_quaternion, 9, include_endpoints=True):
25  my_interpolated_point = q.rotate(my_vector)
26  print('My Interpolated Point: {point}\t(after rotation of {angle} deg about {axis})'.format(
27  point=my_interpolated_point, angle=round(q.degrees, 4), axis=q.axis
28  ))
29 
30 print('Done!')


pyquaternion
Author(s): achille
autogenerated on Sun Mar 15 2020 03:13:33