Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411516 Posts in 69380 Topics- by 58436 Members - Latest Member: GlitchyPSI

May 01, 2024, 05:23:15 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)can any one explain this?
Pages: [1]
Print
Author Topic: can any one explain this?  (Read 1322 times)
Sigma
Level 1
*


View Profile WWW
« on: July 27, 2010, 10:36:36 AM »

This code is from unity default SmoothFollow.js camera script

currentHeight=Mathf.Lerp(currentHeight, wantedHeight, heightDamping * Time.deltaTime);   currentRotation = Quaternion.Euler (0, currentRotationAngle, 0);
transform.position = target.position;
transform.position -= currentRotation * Vector3.forward * distance;

can any one explain this line
             transform.position -= currentRotation * Vector3.forward * distance;
adding a Quaternion (x,y,z,w)(currentRotation) with position(transform.position).

As for as i understand it is something similar to x = x+rcosTheta; but i couldnt visualize whats quaternion role is with W.

Thanks in advance
Logged

BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #1 on: July 27, 2010, 11:50:41 AM »

quaternion * vector * scalar = vector (it rotates it, then scales it)
So you are not adding things of different quantities, you are just adding vectors.
Logged
iggie
Level 1
*



View Profile WWW
« Reply #2 on: July 29, 2010, 11:06:50 AM »

I use quaternions interchangeably with rotation matricies. So this just looks like rotate the unit forward vector into the current direction and then move the position along this vector by the distance to travel.

If you start worrying about what 'w' means you will probably waste a lot of time that could be spent coding gameplay, life is much simpler if you treat Quats as useful black-boxes and don't stop to look inside  Wink
Logged

Sigma
Level 1
*


View Profile WWW
« Reply #3 on: July 30, 2010, 11:49:44 AM »

Thanks for the reply. i guessed right.
Logged

slembcke
Level 3
***



View Profile WWW
« Reply #4 on: July 30, 2010, 01:00:16 PM »

life is much simpler if you treat Quats as useful black-boxes and don't stop to look inside  Wink

I disagree, there are a bunch of custom rotation operators that I've written. Trying to get them to work using the trig style operations ended up being a disaster with domain issues and awful performance. That said, I rather enjoyed figuring it out as well.
Logged

Scott - Howling Moon Software Chipmunk Physics Library - A fast and lightweight 2D physics engine.
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic