Results 1 to 5 of 5

Thread: OK, then simple question about Quats

  1. #1
    Senior Member Frequent Contributor
    Join Date
    Nov 2002
    Location
    Latvia
    Posts
    626

    OK, then simple question about Quats

    How can I create simpe animation, knife movement for example.
    Firstly, I translate it to needed position, rotate it with 3quats, then I calculate how the end position should look like 1 trans +3 quats. Finally, I calculate difference final trans/quat-start trans/quat and every frame call trans/quat+diff*t
    Is that right?

  2. #2
    Senior Member Frequent Contributor
    Join Date
    Aug 2000
    Location
    Cardiff University
    Posts
    653

    Re: OK, then simple question about Quats

    animating along a path... or just simple linear or...?

  3. #3
    Senior Member Frequent Contributor
    Join Date
    Nov 2002
    Location
    Latvia
    Posts
    626

    Re: OK, then simple question about Quats

    Preferably non-linear, it's called Cubic interploration, yes?

  4. #4
    Member Contributor
    Join Date
    Jan 2003
    Location
    coventry
    Posts
    72

    Re: OK, then simple question about Quats

    why 3 quats? you should only need one. If you have a start orientation matrix and an end orientation matrix, convert them to quats, then you can interpolate from one to another, linearly or non linearly.
    ----------------------------
    Non!

  5. #5
    Member Contributor
    Join Date
    Jan 2003
    Location
    coventry
    Posts
    72

    Re: OK, then simple question about Quats

    btw, some quaternion interpolation code

    Code :
     
    bool Vector::Interpolate(const Vector& V0, const Vector& V1, float Fraction)
    {
        float OneMinusFraction = 1.0f - Fraction;
        x = OneMinusFraction * V0.x + Fraction * V1.x;
        y = OneMinusFraction * V0.y + Fraction * V1.y;
        z = OneMinusFraction * V0.z + Fraction * V1.z;
    }
     
     
    bool Quaternion::Interpolate(const Quaternion &Quat1,const Quaternion &Quat2,float Fraction)
    {
    	//--------------------------------------------------------------------------------
    	// There are two quaternions for each orientation, this will cause problems if we don't
    	// eliminate one (i.e. zero crossover problem), so see if quaternions are on opposite sides of a
    	// 4 dimensional hypersphere (the degenerate case) and if so, flip one to the otherside (same 
    	// orientation but now no zero crossover problem)
    	//--------------------------------------------------------------------------------
    	Quaternion NormQuat2 = Quat2;							//Used to get rid of degenerate case
     
    	if ((Quat1.DotProduct(NormQuat2)) < 0.0f)	
    		NormQuat2 *= -1.0f;									//See comment above
     
    	//--------------------------------------------------------------------------------
    	// The degenerate case has been removed, can now interpolate normally
    	//--------------------------------------------------------------------------------
    	V.Interpolate(Quat1.V, NormQuat2.V, Fraction);
     
    	R  = Quat1.R * Fraction;
    	R += NormQuat2.R * (1.0f - Fraction);
     
    	return Normalise();
    }
    ----------------------------
    Non!

Similar Threads

  1. raspberry pi, quats and opengl
    By technologist in forum OpenGL: General
    Replies: 6
    Last Post: 11-21-2017, 11:14 PM
  2. a simple question
    By drdolittle in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 10-31-2008, 09:43 AM
  3. Quats and Shaders
    By ffelagund in forum OpenGL ES
    Replies: 2
    Last Post: 05-19-2005, 06:47 AM
  4. Few questions about Quats
    By M/\dm/\n in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-29-2003, 04:43 AM
  5. moving a camera (quats?)
    By frogger in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 09-02-2000, 03:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean