Simple Matrix Help: Calculate Offsets

  • Context: Undergrad 
  • Thread starter Thread starter Zango93
  • Start date Start date
  • Tags Tags
    Matrix
Click For Summary
SUMMARY

The discussion focuses on calculating offsets in a 3D space using a 4x4 transformation matrix. The user seeks to determine the XYZ coordinates for positions 5 units to the left, right, and back of an object, building on an existing calculation that retrieves the position 5 units ahead. The calculations utilize the transformation matrix obtained from the object's properties, specifically using the matrix's second column to determine directional offsets based on the object's orientation.

PREREQUISITES
  • Understanding of 4x4 transformation matrices in 3D graphics
  • Familiarity with coordinate systems in 3D space
  • Knowledge of matrix multiplication and its application in transformations
  • Basic programming skills to implement matrix calculations
NEXT STEPS
  • Learn how to manipulate 4x4 transformation matrices in a programming language like Python or C++.
  • Study the concepts of local vs. global coordinates in 3D environments.
  • Explore vector mathematics to understand directional offsets in 3D space.
  • Investigate libraries such as GLM (OpenGL Mathematics) for handling matrix and vector operations.
USEFUL FOR

3D game developers, computer graphics programmers, and anyone involved in spatial calculations within a 3D environment will benefit from this discussion.

Zango93
Messages
2
Reaction score
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
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).
 
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.
 

Similar threads

  • · Replies 7 ·
Replies
7
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 9 ·
Replies
9
Views
4K