# Deciding which is dimension is which for rotated quadrangles.

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

## Recommended Posts

I'm creating a quadrangle using the following method:

 // Lower Left -- [d] // Upper Left | | // Lower Right | | // Upper Right [a] -- [c] quadrangle = new Quadrangle( (a + d) * 0.5f, // Position Vector3.Distance(b, d), // Width Vector3.Distance(b, a), // Height Vector3.Normalize(Vector3.Cross(b - a, c - a)), // Normal 64 // Texture Index ); 

The constructor then rotates the quadrangle so that its normal faces in the direction specified:

 private static Matrix RotationFrom(Vector3 normal) { normal.Normalize(); Matrix rotation = Matrix.Identity; rotation.Backward = normal; rotation.Up = Vector3.Cross(Vector3.UnitY, normal); if (rotation.Up.LengthSquared() < MathTools.EPSILON) { rotation.Up = Vector3.Cross(-Vector3.UnitZ, normal); } rotation.Up.Normalize(); rotation.Right = Vector3.Cross(rotation.Up, normal); rotation.Right.Normalize(); return rotation; } 

The problem is that this ruins the method for finding the width and height as they can be swapped around depending on quadrangle orientation. How can I make sure that the dimensions are set correctly so that when the quadrangle transform is scaled:

 worldTransform.M11 *= scale.X; worldTransform.M12 *= scale.X; worldTransform.M13 *= scale.X; worldTransform.M21 *= scale.Y; worldTransform.M22 *= scale.Y; worldTransform.M23 *= scale.Y; 

It takes into account the current orientation?

 E.g. width ------> -- [d] ^ | | | | | | [a] -- [c] height ROTATED height------> [a] -- ^ | | | | | | [c] -- [d] width 

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633722
• Total Posts
3013549
×