# Transforming a 3D vector using matrix

• Gajan
In summary, the conversation discusses the use of a 4x4 matrix for transformation in 3D space. The matrix is capable of both rotation and translation, and it is suggested to use a "projective" space to represent points. The conversation also mentions the possibility of using two rotations around coordinate axes for a general rotation. Finally, the question is asked if the matrix product is done in the same way for a transposed matrix and a row vector.
Gajan
Hi Friends,

I have a problem in transforming a vector in 3d using a matrix.

I have two points A, B. Assume origin is O, here A,B ,O are in 3d.

First construct a vector AB:

OB = OA + AB
AB = OB - OA
AB = OB + AO

I have a 4*4 matrix that gives the transformation matrix(rotation+translation)

I need to transform vector AB using this matrix.

Currently what I do is transform individual points A , B first and the reconstruct the vector A'B' again (after tranforming)
What I want to do is to without doing the above steps, transform the vector as it is (without transforming the individual points). Is this possible?

How could I do this computation?

thank you.

/Gajan

Using a single 4x4 matrix to do both rotation and translation, you have to use a "projective" space. That means you are representing the point (x,y,z) as the (column) vector [x y z 1] with the provision that [a b c d] is the same as [a/d b/d c/d 1] (d can never be 0). In that case the matrix that rotates, say, $\theta$ degrees about the y-axis and translates by (tx,ty, tz) is
$$\begin{bmatrix} cos(\theta) & 0 & -sin(\theta) & tx \\ 0 & 1 & 0 & ty \\ sin(\theta) & 0 & cos(\theta) & tz \\ 0 & 0 & 0 & 1\end{bmatrix}$$
Notice that in the particular case of $\theta= 0$ where there is no rotation and so a pure translation, this becomes
$$\begin{bmatrix} 1 & 0 & 0 & tx \\ 0 & 1 & 0 & ty \\ 0 & 0 & 1 & tz \\ 0 & 0 & 0 & 1\end{bmatrix}\begin{bmatrix} x \\ y \\ z \\ 1\end{bmatrix}= \begin{bmatrix} x+ tx \\ y+ ty \\ z+ tz \\ 1\end{bmatrix}$$

While if tx= ty= tz= 0 so there is a pure rotation and no translation it is
$$\begin{bmatrix} cos(\theta) & 0 & -sin(\theta) & 0 \\ 0 & 1 & 0 & 0 \\ sin(\theta) & 0 & cos(\theta) & 0 \\ 0 & 0 & 0 & 1\end{bmatrix}\begin{bmatrix} x \\ y \\ z \\ 1\end{bmatrix}= \begin{bmatrix} xcos(\theta)- zsin(\theta) \\ y \\ xsin(\theta)+ zcos(\theta)\end{bmatrix}$$

I would handle a general rotation as the product of two rotations around coordinate axes.

Hi,

In my case , I have the matrix in the following form:

Transpose matrix of the transformation : M
vector :V

V * M

still is it the same way the matrix product is done?

Last edited:
Assuming that you are writing V as a row matrix, yes, swapping "row" and "column" is purely a matter of convention.

Thanking you. I understand it now.

## What is a 3D vector?

A 3D vector is a mathematical representation of a quantity that has magnitude and direction in three-dimensional space. It is commonly denoted by u or v and can be represented by three components: x, y, and z.

## What is a matrix?

A matrix is a rectangular array of numbers or symbols that can be used to represent mathematical equations and transformations. It is commonly denoted by A and can have different dimensions, such as 2x2, 3x3, or 4x4.

## How do you transform a 3D vector using a matrix?

To transform a 3D vector using a matrix, we first need to represent the vector as a column matrix (with the x, y, and z components as its rows). Then, we multiply the matrix by the column vector, which results in a new vector with transformed coordinates.

## What types of transformations can be achieved using a matrix?

Matrices can be used to achieve various transformations, such as translation, rotation, scaling, shearing, and reflection. These transformations can be applied to both 2D and 3D vectors, depending on the dimensions of the matrix.

## Why is transforming a 3D vector using a matrix important?

Transforming a 3D vector using a matrix is important because it allows us to manipulate and manipulate objects in three-dimensional space. This is crucial in many fields, such as computer graphics, physics, and engineering, as it enables us to model and analyze real-world scenarios and objects.

• Linear and Abstract Algebra
Replies
12
Views
3K
• Linear and Abstract Algebra
Replies
20
Views
2K
• Linear and Abstract Algebra
Replies
27
Views
1K
• Linear and Abstract Algebra
Replies
2
Views
962
• Linear and Abstract Algebra
Replies
2
Views
1K
• Linear and Abstract Algebra
Replies
3
Views
1K
• Linear and Abstract Algebra
Replies
8
Views
2K
• Linear and Abstract Algebra
Replies
1
Views
983
• Linear and Abstract Algebra
Replies
2
Views
2K
• Linear and Abstract Algebra
Replies
33
Views
1K