![]() Example: given (1, 0, 3) as a first vector, the equation can be solved by a second vector (0, 1, 0). If one of x, y, z is zero, then the above equation can be solved by choosing a non-zero value for the corresponding direction, and setting the other variables to zero. Note that you do not avoid the solution a = b = c = 0, because random.random() can return zero. ![]() You are correct in avoiding the trivial solution x = y = z = 0. Two vectors are perpendicular if their scalar product is zero: 1st vector (x, y, z) I also don't know where the iszero(…) function is from, and will replace it by … = 0 in the following. The same set of these conditions occurs two times, which is a bit confusing. The inverted conditions not iszero(…) don't make it any easier to understand. The lack of comments make it slightly non-obvious what is happening. Now, if I wanted, for example, a vector in the same direction of r with a length of 5, I'd simply multiply out r' * 5, which is. Where r' represents the unit vector of r - a vector with length of 1 that points in the same direction as r does. V = Sqrt(a^2 + b^2 + c^2) <- this is the length of the original vector To turn any vector (except for ) into a unit vector (a vector with a length of 1, in the same direction as the original vector): r = For example, you might want your basis vectors (your coordinate axes) to all be the same size/length. Depending on what you want, this might not be desired. Note that, as you continually do dot products and cross products, your vectors will begin to grow larger and larger. Once you find your two axes and, you can reduce this back to the previous case (case 3), using and as your x and y axes (or whatever axes you need them to be, for your specific problem). but there are many other ones that can work as well there are, in fact, an infinite! One could pick, for example, : 2 * 3 + 3 *-2 + 4 * 0 = 0Īs you can see, one "formula" that works to is =. That is, any value of that satisfies this is a satisfactory orthogonal vector (as long as it's not ). ![]() = arbitrary orthogonal axis (cannot be )įor example, if your original axis is, you'd solve: 2 * d + 3 * e + 4 * f = 0 One way to find an arbitrary one of these orthogonal vectors by finding any vector where: = original axis You can, however, find one of the possible solutions. ![]() However, there are an infinite amount of possible orthogonal vectors to a single axis in 3D space! This is because, if you look at the second case (One axis in an arbitrary-basis 2D coordinate system), you first need to find an orthogonal vector. There is not enough information to find the unique solution this problem. Given: One axis in an arbitrary-basis 3D coordinate system Given: Two axes in an arbitrary-basis 3D coordinate system To rotate a vector orthogonally clockwise: = To rotate a vector orthogonally counter-clockwise: = If you have one axis in an arbitrary-basis 2D coordinate system, the other axis is the orthogonal vector. Given: One axis in an arbitrary-basis 2D coordinate system In a 3D system, your axes/basis are always, , and - x, y, and z. In a 2D system, your axes/basis are always and - x and y axes. I can think of a couple of different scenarios you might be asking about.
0 Comments
Leave a Reply. |