Simple Matrix Help: Calculate Offsets

  • Thread starter Zango93
  • Start date
  • Tags
    Matrix
In summary, the person is looking for a way to retrieve the left or right coordinate of a moving element in a 3D world.
  • #1
Zango93
2
0
Hi,

I am always willing to learn, but currently I don't have the time to learn how matrices work, even though it might be simple, I haven't tried.

I need three calculations for a project I am working on, I have one already.

What I basically need is x units to the right, back and left of an element

'matrix' used below contains four subtables, matrix[1] is a table that has the three values matrix[1][1], matrix[1][2] matrix[1][3] matrix[1][4] for example (multi-dimensional array containing a 4x4 matrix)

this is the matrix calculation I have already, it gets the point 5 units ahead of an element.
Code:
	offset1 = 0 * matrix[1][1] + 5 * matrix[2][1] + 0 * matrix[3][1] + matrix[4][1]
	offset2 = 0 * matrix[1][2] + 5 * matrix[2][2] + 0 * matrix[3][2] + matrix[4][2]
	offset3 = 0 * matrix[1][3] + 5 * matrix[2][3] + 0 * matrix[3][3] + matrix[4][3]

I want to know how to get 5 units to the back, left and right of this element
 
Physics news on Phys.org
  • #2
You're probably wondering why no one has replied. I can't speak for anyone else, but I for one didn't understand the question. Maybe you can explain more carefully. What do you mean by "units?" What do you mean by "right", "left" and "back"? Is left different from back? You said "has three values..." and then mentioned four things. Where those four things supposed to be the three values?

Do you even mean the same thing as we do when you say "matrix"? (I understood almost nothing of what you said, so I have to ask).
 
  • #3
Imagine a 3D world, one unit is one meter, you have an object (example 4 units length, 3 units height and 2 metres wide) and you can retrieve the object's transform matrix in a multi-dimensional array containing a 4x4 matrix.

I misspelled in the above post it is indeed four values in the four arrays of the table 'matrix' (which name doesn't matter btw)

I had code from some time ago which would get a 3D world coordinate 5 units ahead of an element, which I'll post again:

Code:
matrix = getElementMatrix (object)
X = 0 * matrix[1][1] + UNITS_AHEAD * matrix[2][1] + 0 * matrix[3][1] + matrix[4][1]
Y = 0 * matrix[1][2] + UNITS_AHEAD * matrix[2][2] + 0 * matrix[3][2] + matrix[4][2]
Z = 0 * matrix[1][3] + UNITS_AHEAD * matrix[2][3] + 0 * matrix[3][3] + matrix[4][3]

UNITS_AHEAD is the amount of units to go ahead of the element. This was 5 in the initial code posted.

The above calculation gets a point ahead of an element. A car facing north, the above would give me the 3D XYZ coordinate to the north of the north-pointing vehicle (ahead), in the distance I specify under variable UNITS_AHEAD

What I want is, re-assuming the case of our car facing north, the calculation I posted modified so it gets the XYZ coordinate UNITS_AHEAD to the south, east and west.

The problem here is you might get confused by "south east and west". If you stretch your arms so you form a T and turn around, your arms will stay respectively on the left and right side of your body, regardless of the orientation of your body. This is what I want to achieve but with a moving element in a 3D world, to be able to retrieve a "left" or "right" of the element.

Am hoping you understand my request, else I'm sorry.
 

1. What is an offset in a matrix?

An offset in a matrix refers to the difference between a specific element in the matrix and the main diagonal element. It can be calculated for both rows and columns, and is typically used to measure the distance between two elements in the matrix.

2. How do you calculate offsets in a matrix?

To calculate the offset for a specific element in a matrix, you subtract the value of the main diagonal element from the value of the element in question. For example, if the main diagonal element is 5 and the element in the third row and fourth column is 8, the offset would be 8 - 5 = 3.

3. What is the purpose of calculating offsets in a matrix?

Calculating offsets in a matrix can be useful for various reasons. It can help determine the distance between two elements, identify patterns or trends in the data, and aid in solving equations or performing transformations on the matrix.

4. Can offsets be negative in a matrix?

Yes, offsets can be negative in a matrix. This occurs when the element in question is located to the left of or above the main diagonal element. In this case, the offset value would be negative, indicating that the element is a certain number of rows or columns away from the main diagonal element in the opposite direction.

5. How do you use offsets to solve a matrix equation?

If you are using offsets to solve a matrix equation, you would first calculate the offsets for each element in the matrix. Then, you would set the offsets equal to each other and solve the resulting equation to find the unknown variable. This can help simplify the equation and make it easier to solve.

Similar threads

  • Linear and Abstract Algebra
Replies
6
Views
512
Replies
7
Views
829
  • Linear and Abstract Algebra
Replies
5
Views
941
  • Linear and Abstract Algebra
Replies
9
Views
2K
  • Linear and Abstract Algebra
Replies
8
Views
873
  • Linear and Abstract Algebra
Replies
9
Views
1K
  • Linear and Abstract Algebra
Replies
8
Views
784
  • Linear and Abstract Algebra
Replies
13
Views
1K
  • Linear and Abstract Algebra
Replies
8
Views
1K
  • Linear and Abstract Algebra
Replies
4
Views
1K
Back
Top