I tried to google this question several times, but i found only articles about "Rotation matrix".
I have 3d coordinate system and two angles: α for x-rotation and β for y-rotation (I'm not sure if I've positioned the angles correctly in the diagram).
And i need to find coordinates of Vector(x_1, y_1, z_1)
Please, help me to figure out the formulas.
Let's break this up into two transformations.
Starting with your unit vector at (0,0,1), we'll apply the alpha transformation first.
You can treat the rotation about the y-axis as a 2-D transformation and ignore the y-axis entirely. Then it becomes simple trig to get the x and z components with cos and sin of your transformation angle (alpha). We know the length of the vector is 1 since it's a unit vector, but your vector could be any length -- just multiply the cos and sin equations by the length of your vector.
This first transformation leaves us with this formula:
(x1, y, z1) => (sin(alpha), 0, cos(alpha))
Assume your transformation angle starts on the +z axis and as it increases, the angle moves counterclockwise around the y-axis (or on the XZ plane).
For the second transformation, We're rotating around the axis perpendicular to our vector. We will do something very similar, but this time substituting x1 and z1 for our new values sin(alpha) and cos(alpha).
Getting y1 is as simple as taking the sin of your beta angle like before, but transforming x1 and z1 requires us to scale x1 and z1 by the cosine component of this triangle. This is because the relationship between x1 and z1 does not change as we rotate around their perpendicular axis.
Imagine a circle with the center at the origin and a single point on its circumference at (x1, 0, z1). As we rotate the vector around that circle, x1 and z1 scale relative to the center point, but their ratio does not change.
All we have to do is scale both numbers by the cosine component of our beta angle. I labeled that omega here.
This leaves us with a final formula of
(x2, y1, z2) => (cos(beta)*sin(alpha), sin(beta), cos(beta)*cos(alpha))
Related
I have been trying to figure out whether the following problem has a solution. Almost having given up, I would like to ask whether someone can confirm that there is no solution, or maybe give me a hint.
We have two vectors v and w in 3D space and know that the ratio of their magnitudes is ||v|| / ||w|| = 0.8019.
in 3D space an observer would see that they form an angle of 27.017 degrees.
on the other side, an observer in 2D (only seeing the x and z axis), observes an angle of 7.125 degrees between the vectors.
From their view, the vector coordinates are v = (x: 2, z: 1) and w = (x: 3, z: 2).
Is there somehow a way that the 2D observer can calculate the actual angle between these vectors in 3D space?
I would be more than happy for any input. All my tries have failed so far and I just want to know whether there could be a possible solution.
I have solved this problem and get that the values of y1 and y2 are given by this function:
eq1: 0.6439*y2^(2)-y1^(2)=9.785.
Therefore real angle can practically any value, the factor that would narrow this problem down to an actual solution would be the information about where the observer is in the 3d space so that he sees the angle of 27.017º, however, if this is the whole problem, then I can share my solution and process.
Some graphs that I created from my calculations:
The side view of the vectors is directly from the point of view of the x and z axis of the graph, therefore the coordinates of the (x1,z1) and (x2,z2) points(terminal points of the vectors), appear authentic, and not augmented, hence you can use them in your calculations to calculate the coordinates of z1 and z2, which you need to calculate the angle.
V = (x1, y1, z1) V = (2, y1, 1)
W = (x2, y2, z2) W = (3, y2, 2)
Since ||v|| / ||w|| = 0.8019
∴Then sqrt((x1^2)+(y1^2)+(z1^2))/sqrt((x2^2)+(y2^2)+(z2^2)) = 0.8019
∴(x1^2)+(y1^2)+(z1^2)/(x2^2)+(y2^2)+(z2^2) = 0.6430
∴4+(y1^2)+1/9+(y2^2)+4 = 0.6430
∴5+(y1^2) = 8.359 + 0.6430(y2^2)
∴13.359 = 0.6430(y2^2)-(y1^2)
This gives you therefore a function that calculates the other value of y given the some input y.
You can then graph this function using Geogebra.
For all the pairs of values on the curve, together with the fixed values of x and z for both of the vectors you can calculate that the ratio between the magnitudes of the two vectors is equal to 0.8019.
This problem has therefore infinitely many solutions for the angle as there are infinitely many values of z1 and z2 that satisfy the ratio; ||v|| / ||w|| = 0.8019.
Therefore the answer to this problem can be expressed as:
∀Θº∈R:Θº≥0
I have asked a question similar to this before but have since got further and also didn't tag the question right and wanted to get a bit of help on the maths around the question if possible.
I have a 3D sphere with points evenly spaced on its surface of which I know the coordinates. From these coordinates I am trying to define the orientation of some spikes that are coming out of the surface of my sphere along the vector between the centre of the sphere and the point at which the coordinates lie.
The idea is these euler angles will be very helpful in later aligning the spikes so they are all in roughly the same orientation if I am am to box out all of the spikes from an image.
Since the coordinates on the sphere are evenly spaced i can just take the average x, y and z coordinates to give me the centre and I can then draw a vector from the centre to each coordinate in turn.
The euler angles I need to calculate in this case are initially around the z axis, then around the new y axis, and finally again around the new z axis.
My centre point is currently being defined as the average coordinate of all my coordinates. This works as the coordinates are evenly spaced around the sphere.
I then use the equation that states
cos(theta) = dot product of the two vectors / magnitude of each vector multiplied together
on the x and y axis. One of my vectors is the x and y of the vector i am interested in whilst the other is the y axis (0,1). This tells me the rotation around the z axis with the y axis being 0. I also calculate the gradient of the line on this 2D plane to calculate whether I am working between 0 and +180 or 0 and -180.
I then rotate the x axis about the angle just calculated to give me x' using a simple 2D rotation matrix.
I then calculate the angle in the same way above but this time around the y axis using x' and z' as my second vector (where z' = z).
Finally I repeat the same as stated above to calculate the new z'' and x'' and do my final calculation.
This gives me three angles but when I display in matlab using the quiver3 command I do not get the correct orientations using this method. I believe I just do not understand how to calculate euler angles correctly and am messing something up along the way.
I was hoping someone more knowledgeable than me could take a glance over my planned method of euler angle calculation and spot any flaws.
Thanks.
Sometimes was a problem what is the rectangle 3D rotated and be perspective transition (for example in CSS) draw as the tetragon. But we want obtain the rectangle (width, length, Euler angle, perspective) transformed via rotate and perspective draw as the tetragon.
figure
fig.1 points a,c diagonal rectangle(yellow) points A,C diagonal tetragon(shadow) (red)
fig.2 a,b,c,d rectangle points(yellow) A,B,C,D shadow(tetragon) (red)
Solve:
Coordinate system:
The origin of the coordinate system is coincident with diagonals intersection point. Axe Z normal to the tetragon. Axe X crosses point A
a,b,c,d;- ;- rectangular with coordinates
a(x1,y1,z1);
b(x2,y2,z2);
c(x3,y3,z3);
a(x4,y4,z4);
A,B,C,D-shadow. Corner points A(q1,p1,0);
B(q2,p2,0); C(q3,p3,0);
D(q4,p4,0);
k perspective.
In that system of coordinate y1=y3=0.
Fig1.
From similarity transformation triangles is:
x1=1-z1/kq1;
x3=1-z3/kq3
From statement of problem was that diagonal cross is in the origin of the coordinate thus:
z3=-z1 и x3=-x1
Substituting in expression above and equating to each other was :
x1=2*q1*q3/(q3-q1);
z1=(q1+q3)/(q1-q3)*k.
To simplify other calculation imagine that second rectangle diagonal (bd) lie in coordinate system in that Y coordinate of diagonal points is equal zero. In this coordinate system coordinate points b and d was the same as point a and c but we must change z1 to z2, z3 to z4, x1 to x2, x3 to x4,q1 to q2, q3 to q4. To translate from imagine system to real system use rotation coordinate formula (Z axe is the same, z coordinate is equals)
Fig.2
x=x'*cos(a); y=y'*sin(a); The result was:
x2=-x4=2*q2*q4/(q4-q2);
y2=-y4=x2*tan(a);
z2=-z4=(q2+q4)/(q2-q4)k;
tan(a)=(p2-p4)/(q2-q4)
abcd was parallelogram. Diagonal cross point divide diagonal to half. We need to one more expression to make rectangular. Use angle equal 90 degrees. Make scalar multiplication vector of two side in abcd. In coordinate it was:
(a-b)(d-a)=y4y2+(x1-x4)(x1-x2)+(z1-z4)*(z1-z2)=0;
f=(q1*q2-q3q4)(q1*q4-q2*q3)
g=-tan2(a)*q42q22(q1-q3)2+(-q1q2(q3+q4)+q3q4(q1+q2))*(q1q2(q4-q3)+q3q4(q1-q2))
We receive equation to k(perspective): f*k2-g=0, solve it
k=sqrt(g/f).
Collect all formula we get all coordinates of point abcd.
From coordinate of corner is simple to calculate side of rectangular.
Calculating quaternion, rotation matrix, angles see calculate quaternion by coordinate 2 points of object in two positions
I Have the orthographic projection of a unit cube with one of its vertex at origin as shown above. I have the x,y (no z) co ordinates of the projections. I would like to compute the angle of rotation of the plane to get the second orthographic projection from the first one (maybe euler angles??)
Is there any other easy way to compute this?
UPDATE:
Could I use this rotation matrix to get a system of equations in cos, sin angles and the x,y and x',y' and solve them easily? Or is there any easier way to get the angles back? (Am I on the right direction to solve this? )
First method
Use this idea to generate equations:
a1, a2 and a3 are coordinates in the original system, x y are the coordinates you get from the end-result and z is a coordinate you don’t know. This generates 2 equations for every point of the cube. E.g for point 0 with coordinates (-1, -1, 1) these are:
Do this for the 4 front points of the cube and you get 8 equations. Now add the fact that this is a rotation matrix -> the determinant is 1 and you have 9 equations. Solve these with any of the usual algorithms for solving equation systems and you have the transformation matrix. Getting the axis and angle from that is easy via google: http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/
Second method
Naming your points 0, 1, 2, 3 a, b, c, d respectively, you can get the z coordinates of the vectors between them (e.g. b-a) with this idea:
you will still have to sort out if b3-a3 is positive, though. One way to do that is to use the centermost point as b (calculate distance from the center for all points, use the one with the minimal distance). Then you know for sure that b3-a3 is positive (if z is positive towards you).
Now assume that a is (0,0,0) in your transformed space and you can calculate all the point positions by adding the appropriate vectors to that.
To get the rotation you use the fact that you know where b-a did point in your origin space (e.g. (1,0,0)). You get the rotation angle via dot product of b-a and (1,0,0) and the rotation axis via cross product between those vectors.
I have a start point in 3D coordinates, e.g. (0,0,0).
I have the direction I am pointing, represented by three angles - one for each angle of rotation (rotation in X, rotation in Y, rotation in Z) (for the sake of the example let's assume I'm one of those old logo turtles with a pen) and the distance I will travel in the direction I am pointing.
How would I go about calculating the end point coordinates?
I know for a 2D system it would be simple:
new_x = old_x + cos(angle) * distance
new_y = old_y + sin(angle) * distance
but I can't work out how to apply this to 3 dimensions
I suppose another way of thinking about this would be trying to find a point on the surface of a sphere, knowing the direction you're pointing and the sphere's radius.
First of all, for positioning a point in 3D you only need two angles (just like you only needed one in 2D)
Secondly, for various reasons (slow cos&sin, gimbal lock, ...) you might want to store the direction as a vector in the first place and avoid angles alltogether.
Anyway, Assuming direction is initially z aligned, then rotated around x axis followed by rotation around y axis.
x=x0 + distance * cos (angleZ) * sin (angleY)
Y=y0 + distance * sin (Anglez)
Z=z0 + distance * cos (angleZ) * cos (angleY)
Based in the three angles you have to construct the 3x3 rotation matrix. Then each column of the matrix represents the local x, y and z directions. If you have a local direction you want to move by, then multiply the 3x3 rotation with the direction vector to get the result in global coordinates.
I made a little intro to 3D coordinate transformations that I think will answer your question.
3D Coordinates
First, it is strange to have three angles to represent the direction -- two would be enough. Second, the result depends on the order in which you turn about the respective axes. Rotations about different axes do not commute.
Possibly you are simply looking for the conversion between spherical and Cartesian coordinates.