find a vector perpendicular to vector
Very simple mathamatics here, all you need to is find the slope of the vector (& the midpoint if you are talking about line segments), then multiply the slope by -1.
this is only possible in 2 dimensions, in which case its a simple matter of rotating the vector 90 deg, which can be done like this:
output.x = -input.y;
output.y = input.x;
output.x = -input.y;
output.y = input.x;
Quote:Original post by Eelco
this is only possible in 2 dimensions
It is certainly possible in 3D, only the solution will be any vector lying in a plane perpendicular to the original vector.
say your vector is v(x, y, z)
easy take and arbitrary vector say r(y, z, x)
the the cross product will generate a vector perpedicular to both
p = cross (v, r)
further more anorther cross product and to get the basis for cordenate system
t = cross (v * p)
know you have not one but two vectors perpendicular to the first,
easy take and arbitrary vector say r(y, z, x)
the the cross product will generate a vector perpedicular to both
p = cross (v, r)
further more anorther cross product and to get the basis for cordenate system
t = cross (v * p)
know you have not one but two vectors perpendicular to the first,
Given (x,y,z) then (-(y*y+z*z)/x,y,z), (x,-(x*x+z*z)/y,z) and (x,y,-(x*x+y*y)/z) are all orthogonal (perpendicular) to it assuming x, y nor z are zero. If (x,y,z)=(0,0,0) then any vector is orthogonal to it. If (x,y,z)!=(0,0,0) then at least one component is not zero so one of the three vectors will work.
Quote:Original post by Anonymous PosterQuote:Original post by Eelco
this is only possible in 2 dimensions
It is certainly possible in 3D, only the solution will be any vector lying in a plane perpendicular to the original vector.
so the solution to the 3d version of the problem is a plane, not a vector. no unique solution might aswell be no solution at all for all practical intents and purposes.
Quote:Original post by Anonymous Poster
say your vector is v(x, y, z)
easy take and arbitrary vector say r(y, z, x)
the the cross product will generate a vector perpedicular to both
...
So do not choose r == v by accident, since the result will be vector (0/0/0).
Quote:Original post by Eelco
so the solution to the 3d version of the problem is a plane, not a vector. no unique solution might aswell be no solution at all for all practical intents and purposes.
Wrong, since the question was simply to find a vector perpendicular to the first, not to find the ONLY vector perpendicular to the first. There can very well be a practical purpose to finding such a vector. (Btw, the 2D case does not give a unique solution either, even though they all lie along the same line.)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement