Search code examples
c#matrixorthogonalsiemens-nx

Randomly Generate Orthogonal 3x3 Matrix


I'm looking to do some complex part analysis within Seimens NX. I'm looking to implement the double caliper method of measuring a model in order to find the minimum possible box that it could possibly fit into(for machining purposes). I've got all of my measurement code in place, but I am completely baffled by the idea of a construct that can randomly output normalized 3x3 vectors for use as coordinate systems. The part is measured with respect to this coordinate system, so each coordinate system gives a unique "minimum part envelope". Once analyzed, the smallest envelope is selected and displayed.

this is the type of vector I am talking about:
1 0 0
0 1 0
0 0 1

numbers can be any value between -1 and 1, with decimals not only being accepted but pretty much required.

and no, this isn't my homework. More of an individual pursuit in my free time at work.


Solution

  • If you apply a rotation matrix to an already orthogonal matrix, then the result should also be orthogonal.

    So you can redefine your problem as applying a random rotation matrix to the identity matrix.

    Perhaps do one random rotation matrix for each axis (x,y,z) and then apply the matrices themselves in a random order?