# [XNA] Matrix.CreateRotationX

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

## 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 ?

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 on other sites

Those values are really small.

-4.371139E-08 =

-4.371139 * 10^(-8) =

-4.371139 / 10*8 =

-0.00000004371139

##### Share on other sites

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 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 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 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:)

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 13
• 9
• 15
• 14
• 46
• ### Forum Statistics

• Total Topics
634059
• Total Posts
3015298
×

## Important Information

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!