Jump to content

  • Log In with Google      Sign In   
  • Create Account

Trigonometry question


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 belfegor   Crossbones+   -  Reputation: 2610

Like
0Likes
Like

Posted 19 April 2012 - 10:28 AM

If i had a 3D arrow model pointing upwards (0, 1, 0) and i set this:
D3DXMATRIX world, rot;
D3DXMatrixIdentity(&world);
D3DXMatrixRotationAxis(&rot, &D3DXVECTOR3(1.0f, 0.0f, 0.0f), 0.3f);
world = rot * world;
...

How can i obtain new direction arrow is pointing?

Thanks for your time.

Sponsor:

#2 winsrp   Members   -  Reputation: 273

Like
0Likes
Like

Posted 19 April 2012 - 02:03 PM

make a new vector and use the translate function.

#3 belfegor   Crossbones+   -  Reputation: 2610

Like
0Likes
Like

Posted 19 April 2012 - 02:23 PM

I don't see how's that gonna help? I need to obtain direction vector it is "pointing at" after rotation.

#4 Bacterius   Crossbones+   -  Reputation: 8823

Like
1Likes
Like

Posted 19 April 2012 - 03:04 PM

Make a vector pointing (0, 1, 0), i.e. the same direction as your arrow model, and rotate it in the same way. The rotated vector will give you the direction of the arrow model after rotation...

Putting it a different way, choose two vertices on your original arrow model, a vertex on the "bottom" of the arrow and a vertex of the "top" (the pointy end) of the arrow. These two points define a vector, which points in the arrow's direction. Once your model is rotated, find those two same vertices, they define another vector, which still represents the arrow's direction (obviously). The conclusion trivially follows...

The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

 

- Pessimal Algorithms and Simplexity Analysis


#5 belfegor   Crossbones+   -  Reputation: 2610

Like
0Likes
Like

Posted 19 April 2012 - 03:11 PM

D3DXMatrixRotationAxis(&rot, &D3DXVECTOR3(1.0f, 0.0f, 0.0f), 0.1f);

D3DXVECTOR4 orgDir(0.0f, 1.0f, 0.0f, 0.0f);
D3DXVECTOR4 outDir;
D3DXVec4Transform(&outDir, &orgDir, &rot);

Is this what you mean?

#6 Bacterius   Crossbones+   -  Reputation: 8823

Like
1Likes
Like

Posted 19 April 2012 - 03:18 PM

Yes, although you want to use

D3DXMatrixRotationAxis(&rot, &D3DXVECTOR3(1.0f, 0.0f, 0.0f), 0.3f);

as the rotation matrix (says 0.1 in your last post but 0.3 in the first one)

The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

 

- Pessimal Algorithms and Simplexity Analysis


#7 belfegor   Crossbones+   -  Reputation: 2610

Like
1Likes
Like

Posted 19 April 2012 - 03:20 PM

It was my mistake, It was a typo. Thanks for your help. Posted Image

#8 Trienco   Crossbones+   -  Reputation: 2170

Like
0Likes
Like

Posted 19 April 2012 - 10:03 PM

Or, since you already know that your model was pointing along one of the coordinate system axes, you could just read out the second column of the world matrix. (Transformation) matrices aren't magic, they are just four vectors: right, up, forward, position. (depending on your handedness and as what you define your x,y,z axes).
f@dzhttp://festini.device-zero.de

#9 belfegor   Crossbones+   -  Reputation: 2610

Like
0Likes
Like

Posted 20 April 2012 - 02:54 AM

I don't see how that would be correct?
I tried it and its almost similar, apart that 'z' axis is negative if i extract it from second column of world.

Posted Image

#10 Trienco   Crossbones+   -  Reputation: 2170

Like
0Likes
Like

Posted 20 April 2012 - 08:49 AM

Read the values from your world matrix before applying the rotation, just to be sure you are looking at the correct column. My point is that after setting it to identity, the second column must be (0,1,0,0). I see no reason why applying the same transformation to the same vectors should return different results just because one is transforming the whole matrix and the other a standalone vector.

Though I notice you are transforming orgDir by rot instead of the world matrix. How would that help if your world matrix has already acumulated several rotations? I can't imagine you want to keep track of (and update) a ton of vectors every time you apply a rotation to the world matrix.
f@dzhttp://festini.device-zero.de




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS