Jump to content
  • Advertisement
Sign in to follow this  

Deciding which is dimension is which for rotated quadrangles.

This topic is 2810 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

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)

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.Right = Vector3.Cross(rotation.Up, normal);

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?


width ------>

-- [d] ^
| | |
| | |
[a] -- [c] height



[a] -- ^
| | |
| | |
[c] -- [d] width

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!