Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

998267 Posts in 39150 Topics- by 30560 Members - Latest Member: kust

April 18, 2014, 01:23:31 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)The Small Questions Topic™
Pages: [1]
Print
Author Topic: The Small Questions Topic™  (Read 448 times)
omgnoseat
Level 3
***



View Profile
« on: March 02, 2013, 01:30:01 PM »

I've seen this on a different forum, and it has been icredibly helpful, and probably prevents a lot of unnecessary topics.

So ask all your small questions that don't diserve it's own topic here.

Example

Question
Quote
How do I invert a boolean?

Anwser
Quote
boolean = !boolean
Logged

omgnoseat
Level 3
***



View Profile
« Reply #1 on: March 02, 2013, 01:33:23 PM »

Now for my own question;

I have a vehicle class that a Vector3 velocity. How could I figure out the velocity in it's forward direction? (forward as in front of the vehicle's rotation)
Logged

evelynjolie
Level 10
*****



View Profile
« Reply #2 on: March 02, 2013, 01:49:13 PM »

dum this is a trick to mak me do math
Logged

my website/tumblr (devlog): http://evajolli.com/
Polly
Level 3
***


View Profile
« Reply #3 on: March 02, 2013, 02:07:43 PM »

I have a vehicle class that a Vector3 velocity. How could I figure out the velocity in it's forward direction? (forward as in front of the vehicle's rotation)

Create a matrix from your rotation, multiply the vector with the matrix, get the axis that represents the forward direction.
Logged
nikki
Level 10
*****


View Profile Email
« Reply #4 on: March 02, 2013, 02:22:25 PM »

good idea for thread!
Logged
omgnoseat
Level 3
***



View Profile
« Reply #5 on: March 02, 2013, 02:42:17 PM »

I have a vehicle class that a Vector3 velocity. How could I figure out the velocity in it's forward direction? (forward as in front of the vehicle's rotation)

Create a matrix from your rotation, multiply the vector with the matrix, get the axis that represents the forward direction.
Fortunately I already have the matrix. That does sound very logical, but unfortunately this does not seem to return any logical values.

Code:
car.transform.transformVector(car.velocity).z; //actionscript3 matrix/vector3D classes

EDIT: seemed like I needed to invert the matrix first, not sure why, but it does the trick!
« Last Edit: March 02, 2013, 03:13:29 PM by omgnoseat » Logged

Pishtaco
Level 10
*****



View Profile WWW
« Reply #6 on: March 02, 2013, 03:02:39 PM »

Now for my own question;

I have a vehicle class that a Vector3 velocity. How could I figure out the velocity in it's forward direction? (forward as in front of the vehicle's rotation)

Dot product with a unit vector in the forward direction.
Logged

Polly
Level 3
***


View Profile
« Reply #7 on: March 02, 2013, 03:28:10 PM »

seemed like I needed to invert the matrix first, not sure why, but it does the trick!

If you already have a rotation / transformation matrix for whatever reason, use the dot product solution as proposed by Pishtaco ( get the unit vector from that matrix ). Inverting a matrix is slow ( depending on your rotation representation creating the correct matrix directly could be allot faster though ).
Logged
ham and brie
Level 3
***



View Profile Email
« Reply #8 on: March 02, 2013, 03:38:20 PM »

Inverting the matrix omgnoseat has would make sense if it is the rotation from local space of the vehicle to world space.

The inverse of a rotation matrix is the transpose, so it's pretty easy to get values out needed for the dot product either way.
Logged
eddietree
Level 6
*


I consume memory, therefore I am.


View Profile WWW Email
« Reply #9 on: March 04, 2013, 05:37:48 AM »

dot product, yo
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic