Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8722871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:30:09+00:00 2026-06-13T07:30:09+00:00

I need to create a 4×4 matrix class for a 3D engine in C#.

  • 0

I need to create a 4×4 matrix class for a 3D engine in C#.
I have seen some other engines storing the matrix values in single float member variables / fields like this:

float m11, m12, m13, m14
float m21, m22, m23, m24
float m31, m32, m33, m34
float m41, m42, m43, m44

However, I thought storing them in a two dimensional array would be more useful for transformations / calculations with the matrices:

float[4][4];

I also thought of a one dimensional array – but it looks less self explanatory and wouldn’t give me an advantage over the first option:

float[16];

In C++, I always used the “union” keyword to have all of the above storing possibilites at once. However, C# does not seem to have this keyword, so I have to decide which one I want to use.

What is the fastest way of storing the 4×4 matrix when applying transformations etc.?
Which option would you choose when thinking about usability?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:30:10+00:00Added an answer on June 13, 2026 at 7:30 am

    You could use a two dimensional array:

    float[,] matrix = new float[4,4];
    

    This is different than a jagged array:

    float[][] matrix = new float[][4];
    

    A two dimensional array is, underneath, stored as one big one dimensional array. The class simply abstracts that away from you and provides accessors that provide two (or more) dimensions. Because it is stored as a one dimensional array in the back end you will maintain cache/memory locallity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help with a query. I have this simple table: CREATE TABLE
Using boost python I need create nested namespace. Assume I have following cpp class
i need create a variable with parent subclass. Example: Parent Class <?php class parentClass
I have dynamically created WrapPanel (_wp) with several Borders. And I need create handler
I need to create a WP site which will have multiple subjects. Each subject
I need to create a class with two properties: LogOutput ExceptionOutput These properties (Actions<>)
I need create three random links to other posts, in my post view function.
I need create custom tabbar with super class UITabBarController. But i don,t know how
I create service and I need create class MyErrors (not exception) My web method
I have starting date and number of months. I need to create specific number

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.