Ogre::Vector3::Slerp ??

Problems building or running the engine, queries about how to use features etc.
Post Reply
Van
Hobgoblin
Posts: 512
Joined: Fri Nov 19, 2004 3:56 am
Contact:

Ogre::Vector3::Slerp ??

Post by Van »

Is there an Ogre::Vector3::Slerp or equivelent? Or is there another method?

My goal is to "slerp" (correct) a network player position. The Ogre::Quaternian::slerp works great for this, I am not sure how I would do it with a Vector3.

Not being a math guru, and from what I thought I understand of Quats, I thought I could do it with a quat by flipping "w" but that was a no good. However, on the flip side I figure out how to distort an image. ;)
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67
Contact:

Post by sinbad »

Slerp means 'spherical linear interpolation' so it has no relevance to Vector3. You just mean 'lerp', which is a simple case of linearly interpolating the components of the vector.
Van
Hobgoblin
Posts: 512
Joined: Fri Nov 19, 2004 3:56 am
Contact:

Post by Van »

Sometimes I make things more difficult than they are... :roll:

For future readers:

Code: Select all


// simple linear interpolation between two points
Ogre::Vector3 lerp (Ogre::Vector3 &srcLocation, Ogre::Vector3 &destLocation, Ogre::Real Time)
{
  Ogre::Vector3 mDest; 
  mDest.x = srcLocation.x + (destLocation.x - srcLocation.x) * Time;
  mDest.y = srcLocation.y + (destLocation.y - srcLocation.y) * Time;
  mDest.z = srcLocation.z + (destLocation.z - srcLocation.z) * Time;
  return mDest;
}

or put simply

Code: Select all


Ogre::Vector3 lerp (Ogre::Vector3 &srcLocation, Ogre::Vector3 &destLocation, Ogre::Real Time)
{

  return srcLocation + (destLocation - srcLocation) * Time;
}

Post Reply