![]() |
|
#1
|
|||
|
|||
Damn, forgot about that acos. Then to get no rotation I need to use w=-1: 2*acos(-1) = 360 degrees. Thanks again farshizzo!
EDIT: The following code makes MainView look down X. Code:
import viz viz.go(viz.FULLSCREEN) ROTATION_INC = 2 TRANSLATE_INC = 0.1 i = 0 while (i < 10): redBall = viz.add("white_ball.wrl") redBall.setPosition([i, 0, 0]) redBall.color([1 - 0.1*i, 0, 0]) greenBall = viz.add("white_ball.wrl") greenBall.setPosition([0, i, 0]) greenBall.color([0, 1 - 0.1*i, 0]) blueBall = viz.add("white_ball.wrl") blueBall.setPosition([0, 0, i]) blueBall.color([0, 0, 1 - 0.1*i]) i += 0.1 viz.MainView.setQuat([0,1,0,-1]) viz.MainView.setPosition(5, 0, 0.5) vizact.whilekeydown(viz.KEY_UP, viz.move, 0, 0, TRANSLATE_INC) vizact.whilekeydown(viz.KEY_DOWN, viz.move, 0, 0, -TRANSLATE_INC) vizact.whilekeydown(viz.KEY_LEFT, viz.rotate, viz.BODY_ORI, -ROTATION_INC, 0, 0) vizact.whilekeydown(viz.KEY_RIGHT, viz.rotate, viz.BODY_ORI, ROTATION_INC, 0, 0) vizact.whilekeydown(viz.KEY_PAGE_UP, viz.rotate, viz.HEAD_ORI, 0, -ROTATION_INC, 0) vizact.whilekeydown(viz.KEY_PAGE_DOWN, viz.rotate, viz.HEAD_ORI, 0, ROTATION_INC, 0) ![]() Last edited by roman_suvorov; 06-11-2008 at 06:10 PM. |
#2
|
|||
|
|||
Now you're dealing with non-normalized quaternions, so all bets are off. In general, you don't need to deal with quaternions at such a low level. You can use Vizards matrix routines to deal with rotation transformations.
|
#3
|
|||
|
|||
![]() Quote:
For example, add this function definition to my previous code: Code:
# Normalizes the passed quaternion (which is assumed to have the form # [x,y,z,w]) so that the vector [x,y,z,w] has unit length. # Note: normalization is done in place (i.e., the correct way # of calling this function is 'normalizeQuat(q1)' rather than 'q1 = normalizeQuat(q2)'. def normalizeQuat (quat): i = 0 normFactor = 0 while (i < len(quat)): normFactor += quat[i]**2 i += 1 normFactor = normFactor**0.5 i = 0 while (i < len(quat)): quat[i] /= normFactor i += 1 Unfortunately, seems like I do. This little script is just a way to fill in the gaps I have in my understanding of quaternions. |
#4
|
|||
|
|||
Yes, Vizard will internally normalize all quaternions that are passed to the setQuat function of nodes, views, and bones.
|
![]() |
Thread Tools | |
Display Modes | Rate This Thread |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
coalesceing euler angles | epl | Vizard | 6 | 05-28-2004 05:25 PM |
plug-ins that return quaternions | hotspur1 | Vizard | 2 | 02-05-2004 07:47 PM |