Simple matrix help

  • Thread starter Zango93
  • Start date
  • #1

Main Question or Discussion Point


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.
	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

Answers and Replies

  • #2
Staff Emeritus
Science Advisor
Gold Member
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:

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.

Related Threads on Simple matrix help

  • Last Post