Jump to content
  • Advertisement
Sign in to follow this  
montify

[XNA] Matrix.CreateRotationX

This topic is 987 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, 

 

I have a question: 

 

When i create a Rotation Matrix like:

result = Matrix.CreateFromAxisAngle(new Vector3(0, 1, 0), MathHelper.ToRadians(90.0f));

Why i have on M11 and M33 a pretty high Value?:

 

E in a value means Exponent ? 

 

 

rota.PNG

 

 

 

When i transform this Matrix with a Vector:

nw = new Vector3(-1, 0, 1); 
ne = new Vector3(1, 0, 1); 
sw = new Vector3(-1, 0, -1); 
se = new Vector3(1, 0, -1); 

nw = Vector3.Transform(nw, world);
ne = Vector3.Transform(ne, world);
sw = Vector3.Transform(sw, world);
se = Vector3.Transform(se, world);

i get:


{X:-1 Y:-1 Z:-4,371139E-08}
{X:1 Y:-1 Z:-4,371139E-08}
{X:-1 Y:1 Z:4,371139E-08}
{X:1 Y:1 Z:4,371139E-08}

Is the Y-Value correct? 

Edited by montify

Share this post


Link to post
Share on other sites
Advertisement

Those values are really small.

-4.371139E-08 =

-4.371139 * 10^(-8) =

-4.371139 / 10*8 =

-0.00000004371139

Share this post


Link to post
Share on other sites

Thank you for Reply

 

the thing is: is have 6 flat grids (33x33 Vertices) i would translate each grid to a Cube. Should the number not -1 or 1 ? Why is it so tiny?

Share this post


Link to post
Share on other sites

No, main axis rotation with angles of multiples of 90° will yield 1, -1 or 0. Those small values are practically 0 so you're (usually) fine.

 

Rotation matrices are calculated using trigonometric functions and due to limited precision this small bias can happen. If that poses a problem (e.g. cracks in your cube mesh), hardcode those matrix values or the whole cube mesh.

Share this post


Link to post
Share on other sites

Here an implementation of rotation on the X-axis to show you what happens :

void CMatrix4::SetRotationX( const float Angle )
{
  const float Cos = CMath::Cos( Angle );
  const float Sin = CMath::Sin( Angle );
  m44[ 0 ][ 0 ] = 1.0f; m44[ 0 ][ 1 ] = 0.0f; m44[ 0 ][ 2 ] = 0.0f; m44[ 0 ][ 3 ] = 0.0f;
  m44[ 1 ][ 0 ] = 0.0f; m44[ 1 ][ 1 ] = Cos;  m44[ 1 ][ 2 ] = -Sin; m44[ 1 ][ 3 ] = 0.0f;
  m44[ 2 ][ 0 ] = 0.0f; m44[ 2 ][ 1 ] = Sin;  m44[ 2 ][ 2 ] = Cos;  m44[ 2 ][ 3 ] = 0.0f;
  m44[ 3 ][ 0 ] = 0.0f; m44[ 3 ][ 1 ] = 0.0f; m44[ 3 ][ 2 ] = 0.0f; m44[ 3 ][ 3 ] = 1.0f;
}

Share this post


Link to post
Share on other sites

Thank you guys for answer, i hardcoded the Matrix.

 

But i have another issue.

 

My Planet is normalized Cube with six side.

 

I create the Noise Value like here described:

https://britonia.wordpress.com/2009/12/23/noise-part-iii-gpu/

 

The Noise generated for each patch, so the PixelShader needs the Coordinate of the patch (xNW, xNE, xSW).

 

For the root Patch ( without subedived the quadtree it´s):


 nw = new Vector3(-1,0, 1);
 ne = new Vector3(1, 0, 1);
 sw = new Vector3(-1, 0, -1);

Assume this is for the TopSide of the Cube.

 

How i get the noise for the Front side of the Cube?

 

It´s a 3d noise Funtion in the Shader so how i can translate the nw, se, sw Vector to match the front side (when i pass the right Value i have no seams on the Cube Faces like:)

 

seams.PNG

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!