Vectors

Started by
10 comments, last by apatriarca 12 years, 9 months ago
Hi,
I have a cube in 3d space with the following dimensions (2, 3, 0.75)
now i am going to rotate this cube on the Z axis by -90.

so now my cube is (3, -2, 0.75)

Now with this rotated cube i want to add a change delta of (0, 3, 0) however after the rotation above adding 3 to my Y axis is no longer correct.

How can i work this out?

Gary
Advertisement
I'm afraid you need to be more precise with your language for me to understand what you are asking.
  • Do you really mean dimensions of a cube and not coordinates of a point?
  • What is a "change delta"? Is it a translation?
  • What do you mean by "no longer correct"? Perhaps you wanted to apply the translation before the rotation, or do something after the rotation that would have the same effect?
If you could post a diagram it would be good.
Hi Alvaro,

Okay lets make P= (2, 3, 0.75) a point in space.
If i rotate P by a rotation matrix with Z=-90
P now equals (3,-2,0.75)
and delta is a translation d=(0,3,0)

Now i want to add the delta (0, 3, 0). which is an increase in the Y axis to P (3, -2, 0.75), however after rotation P.y is actually P.x

How do i work out which part of P the x, y or z to add the 3 in the y translation too.



Gary
So you want to end up with (6, -2, 0.75)? You can apply the rotation matrix to the translation vector before you add it.
okay change of plan, sorry

I have a vector(1,2,3) defining how much to change width, height and depth dimensions of a cube.
lets define the cube as being 2 wide, 3 high and 1 deep.
I also know the amount of rotation applied to the cube. (0,0, 90)
so the cube after rotation is now 3 wide, -2 high and still 1 deep.

I then apply this rotation to the change vector(1, 2, 3)

before the cube had rotation adding this change (1,2,3) was easy. however after the rotation the X and Y axis have swapped.

so now after rotation of the change, change will = (-2, 1, 3)

which to me seems correct, this says to me, grow the cube -2 in the X direction, 1 in the Y direction, and 3 in the Z direction.

however if i change my rotation to (45, 0, 90)
apply rotation to change vector(1, 2, 3)
so now after rotation of the change, change will = (0.70, 1, 3.535)

which seems incorrect, this says grow the cube 0.7 in X direction, 1 in the Y direction and 3.535 in the Z direction.

because Z is now X dimension, X is now Y dimension and Y is now Z dimension



Gary
I don't understand cubes with different dimensions, and I understand even less cubes with negative dimensions.

My guess is that you are trying to manipulate axis-aligned boxes, but after a rotation they are no longer axis aligned, which is making your computations break.

Perhaps you should take a step back and describe why you are interested in these modifications of dimensions of "cubes".
I am using directx and defining cubes to represent blocks of wood. with these blocks of wood i am building a cabinet
so a standard sheet of plywood might be 4 foot X 4 foot X 3/4 inch, then this piece of plywood might be rotated to become the left side of the cabinet. rotated on the Y axis by -90 degrees
User might require the cabinet depth or height to change by a certain amount. so i need to know which dimension of the plywood sheet to add the change too. since after the -90 degree rotation the axis are swapped.
I don't know if your familiar with vb.net but here is the code.



Dim v as new vector3(1,2,3)
Dim radian as single = 0.0174532925
Dim qx as Quaternion = Quaternion.RotationAxis(new Vector3(1,0,0), 45 * radian)
Dim qy as Quaternion = Quaternion.RotationAxis(new Vector3(0,1,0), 0 * radian)
Dim qz as Quaternion = Quaternion.RotationAxis(new Vector3(0,0,-1), -90 * radian)
Dim zz as matrix = Matrix.RotationQuaternion(qz * qx * qy)
Dim rb as vector3 = vector3.TransformCoordinate(v, zz)




if i change qx to 0 degree and qz to 90 i get acceptable results i think

same with qx to 0 and qz to -90

and if i leave the code with 45,0,-90 it seems okay i think

Gary

I don't understand cubes with different dimensions, and I understand even less cubes with negative dimensions.

My guess is that you are trying to manipulate axis-aligned boxes, but after a rotation they are no longer axis aligned, which is making your computations break.

Perhaps you should take a step back and describe why you are interested in these modifications of dimensions of "cubes".


Yes, this may be the problems, axis-aligned boxes, making computations break

Gary
front-1.jpg

This topic is closed to new replies.

Advertisement