projections of 3d vector on respective planes - math

I have a 3d vector defined by start and end coordinates (x0,y0,z0 and x1,y1,z1). Also I know the angles made by this vector to the x,y,z axes. Does some one know how do I get to know the angles induced by the vector in xy, yz and zx planes?

Projection of given segment to OXY plane is segment with coordinates (x1, y1) - (x2, y2).
It forms angle relative to OX-axis:
Axy = atan2(y2-y1, x2-x1)
Angle between segment and its projection on OXY plane is
Pxy = arcsin((z2 - z1) / Sqrt((x2-x1)^2 + (y2-y1)^2 + (z2-z1)^2)

Related

Finding a point in 3d space on a plane using 2d coordinates

visualization
I am searching the location of a point that lies on a plane. The relative location on the plane is given in u/v-Coordinates.
The normal vector n is equal to the vector from (0,0,0) to the center of the plane (or any other distance ≠ 0, if more convenient)
The plane has no rotation around the n vector - u is always on the xy axis and v on the z (up) axis
I feel like there should be a simple formula for this, given Vector3 n along with the coordinates u and v, but i'm stuck here.
You have the coordinates of the origin of the plane, namely (x, y, z)
Now we need the unit vectors u and v in global coordinates.
u is (y, -x, 0), normalized.
v is (-zx/r, -zy/r, r), normalized, where r=(x2+y2)1/2
Now you can add the location of the point in uv coordinates to the location of the plane origin in xyz coordinates.

Panning via normal vector and plane

I have got a camera and the direction it is looking at. Therefore I can create a plane out of this direction vector if I take it as a normal vector. So now I want to move my camera which should be on this plane along the plane. Everything's in 3D but I couldn't come up with an idea how to do so. How can I implement the navigational method of panning - so moving in this specific plane?
To pan your camera to the left and to the right you need to know not only lookAt direction, but also up direction for the camera. Then you can calculate cross product of lookAt and upAxis and this gives you direction to the right, negated vector gives you direction to the left.
Definition: A vector N that is orthogonal to every vector in a plane is called a normal vector to the plane.
An equation of the plane containing the point (x0, y0, z0) with normal vector N = (A, B, C), is A(x − x0) + B(y − y0) + C(z − z0) = 0.
Note: The equation of any plane can be expressed as Ax + By + Cz = D.
This is called the standard form of the equation of a plane. From the eqn you can get any other point you want on the plane.
Example: A plane passing through the point P = (1, 6, 4) and the normal vector, R = (2, - 3, - 1). Then the eqn is,
2(x-1) - 3(y-6) - (z-4) = 0
=> 2x - 3y - z = -20

3d points to rotation matrix of orientation

I have 2 3d points:
point1 = (x1, y1, z1).
point2 = (x2, y2, z2).
I want to calculate the rotation matrix R of orientation of the vector between this two points.
The translation of this vector is:
A = (x1-x2, y1-y2, z1-z2).
How I can calculate this? (In easy and efficient calculation/implement).
c++ code is optional.
I am using Egan and GTSAM libraries.

Converting from spherical coordinates to cartesian around arbitrary vector N

So if I'm given an arbitrary unit vector N and another vector V defined in spherical coordinates theta (polar angle between N and V) and phi (azimuthal angle) and r = 1. How do I convert vector V into cartesian coordinates?
Now, I know that in general the conversion from spherical to cartesian is as follows:
x = r * sin theta * cos phi
y = r * sin theta * sin phi
z = r * cos theta
However, since the angles theta and phi are defined respective to the vector N and not the axes, the above conversion wouldn't work, yes? So how would I go about modifying the conversion?
I feel that this is simply not possible given the information you have to hand.
You cannot have a vector V with spherical polar components defined relative to another vector. In a standard spherical polar coordinate system, the coordinates of a point P are given by (r,theta,phi) where theta is the polar angle, phi azimuthal angle, and r the Euclidean distance from the origin. The polar angle is the angle between the z-axis and the line joining the origin to the point P. The azimuthal angle is defined as the angle between the x-axis and the line that joins the origin to the orthogonal projection of P onto the xy plane.
Sometimes the definitions of these two angles are reversed. The above is clearly illustrated at the wiki page http://en.wikipedia.org/wiki/Spherical_polars
The point here is that the angles are defined relative to two mutually orthogonal axes - z and x in this case. Thus you cannot have both of your polar and azimuthal angles defined relative to a single vector N - You can have ONE of them measured relative to N but not both.
As it stands, your problem cannot be solved without providing another vector orthogonal to your N that provides the axis to which the other angle (either polar or azimuthal) is measured.
Your description of N indicates that this is the z-axis of some rotated coordinate system that V takes its polar angle relative to. You need another vector that gives the x-axis of the same rotated coordinate system that V takes measures its azimuthal angle relative to. With that information you can obtain the rotation matrix that maps your rotated coordinate system axes onto the cartesian coordinate axes - from there you will have sufficient information to obtain the cartesian coordinates of V that you require.
Look at this one: http://www.ewerksinc.com/refdocs/coordinate%20and%20unit%20vector.pdf
On page 7 you'll find the conversion formulas between spherical and cartesian vectors.

3d orthogonal projection on a plane

I have a point in 3d P(x,y,z) and a plane of view Ax+By+Cz+d=0 . A point in plane is E.Now i want to project that 3d point to that plane and get 2d coordinates of the projected point relative to the point E.
P(x,y,z) = 3d point which i want to project on the plane.
Plane Ax + By + Cz + d = 0 , so normal n = (A,B,C)
E(ex,ey,ez) = A point in plane ( eye pos of camera )
What i am doing right now is to get nearest point in plane from point P.then i subtract that point to E.I suspect that this is right ???
please help me.Thanks.
The closest point is along the normal to the plane. So define a point Q that is offset from P along that normal.
Q = P - n*t
Then solve for t that puts Q in the plane:
dot(Q,n) + d = 0
dot(P-n*t,n) + d = 0
dot(P,n) - t*dot(n,n) = -d
t = (dot(P,n)+d)/dot(n,n)
Where dot((x1,y1,z1),(x2,y2,z2)) = x1*x2 + y1*y2 + z1*z2
You get a point on the plane as p0 = (0, 0, -d/C). I assume the normal has unit length.
The part of p in the same direction as n is dot(p-n0, n) * n + p0, so the projection is p - dot(p-p0,n)*n.
If you want some coordinates on the plane, you have to provide a basis/coordinate system. Eg two linear independent vectors which span the plane. The coordinates depend on these basis vectors.

Resources