generating two orthogonal vectors that are orthogonal to a particular direction

Physicist

What is the simplest and most efficient ways in numpy to generate two orthonormal vectors a and b such that the cross product of the two vectors equals another unit vector k, which is already known?

I know there are infinitely many such pairs, and it doesn't matter to me which pairs I get as long as the conditions axb=k and a.b=0 are satisfied.

behzad.nouri

This will do:

>>> k  # an arbitrary unit vector k is not array. k is must be numpy class. np.array
np.array([ 0.59500984,  0.09655469, -0.79789754])

To obtain the 1st one:

>>> x = np.random.randn(3)  # take a random vector
>>> x -= x.dot(k) * k       # make it orthogonal to k
>>> x /= np.linalg.norm(x)  # normalize it

To obtain the 2nd one:

>>> y = np.cross(k, x)      # cross product with k

and to verify:

>>> np.linalg.norm(x), np.linalg.norm(y)
(1.0, 1.0)
>>> np.cross(x, y)          # same as k
array([ 0.59500984,  0.09655469, -0.79789754])
>>> np.dot(x, y)            # and they are orthogonal
-1.3877787807814457e-17
>>> np.dot(x, k)
-1.1102230246251565e-16
>>> np.dot(y, k)
0.0

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

In matlab, generating a matrix by adding the elements of two orthogonal vectors

From Dev

In matlab, generating a matrix by adding the elements of two orthogonal vectors

From Dev

How to generate a vector that orthogonal to other vectors?

From Dev

If two plane orthogonal with each other, the transparency of the first plane is wrong

From Dev

Orthogonal and Combinatorial testing techniques

From Dev

orthogonal projection with numpy

From Dev

Daubechies orthogonal wavelet in python

From Dev

Numerical evaluation of orthogonal polynomials

From Dev

Order orthogonal polygon python

From Dev

Converting perspective projection to orthogonal projection

From Dev

Orthogonal Projection of Point onto Line

From Dev

Orthogonal Projection of Point onto Line

From Dev

zgeev giving eigenvectors which are not orthogonal

From Dev

When are hash functions orthogonal to each other?

From Dev

How to use orthogonal data to sort in DataTables?

From Dev

Is there a relationship between CRDTs and the RAFT protocol - or are they orthogonal?

From Dev

Draw non-orthogonal axis in matplotlib?

From Dev

Orthogonal distance regression in python: meaning of returned values

From Dev

Orthogonal projection of a point onto a line in processing?

From Dev

Question: Finding overlapping rectangles in an orthogonal Polygon (Java)

From Dev

What type of orthogonal polynomials does R use?

From Dev

Draw non-orthogonal axis in matplotlib?

From Dev

Orthogonal distance regression in python: meaning of returned values

From Dev

How to make orthogonal edges with cytoscape.js

From Dev

How to detect if all the rows of a non-square matrix are orthogonal in python

From Dev

poly() in lm(): difference between raw vs. orthogonal

From Dev

Calculating the angle of an orthogonal triangle using the Arcsin in C#

From Dev

Draw a square orthogonal to a vector3 (three.js)

From Dev

Sorting jquery DataTables on JSON object property - using Orthogonal data

Related Related

  1. 1

    In matlab, generating a matrix by adding the elements of two orthogonal vectors

  2. 2

    In matlab, generating a matrix by adding the elements of two orthogonal vectors

  3. 3

    How to generate a vector that orthogonal to other vectors?

  4. 4

    If two plane orthogonal with each other, the transparency of the first plane is wrong

  5. 5

    Orthogonal and Combinatorial testing techniques

  6. 6

    orthogonal projection with numpy

  7. 7

    Daubechies orthogonal wavelet in python

  8. 8

    Numerical evaluation of orthogonal polynomials

  9. 9

    Order orthogonal polygon python

  10. 10

    Converting perspective projection to orthogonal projection

  11. 11

    Orthogonal Projection of Point onto Line

  12. 12

    Orthogonal Projection of Point onto Line

  13. 13

    zgeev giving eigenvectors which are not orthogonal

  14. 14

    When are hash functions orthogonal to each other?

  15. 15

    How to use orthogonal data to sort in DataTables?

  16. 16

    Is there a relationship between CRDTs and the RAFT protocol - or are they orthogonal?

  17. 17

    Draw non-orthogonal axis in matplotlib?

  18. 18

    Orthogonal distance regression in python: meaning of returned values

  19. 19

    Orthogonal projection of a point onto a line in processing?

  20. 20

    Question: Finding overlapping rectangles in an orthogonal Polygon (Java)

  21. 21

    What type of orthogonal polynomials does R use?

  22. 22

    Draw non-orthogonal axis in matplotlib?

  23. 23

    Orthogonal distance regression in python: meaning of returned values

  24. 24

    How to make orthogonal edges with cytoscape.js

  25. 25

    How to detect if all the rows of a non-square matrix are orthogonal in python

  26. 26

    poly() in lm(): difference between raw vs. orthogonal

  27. 27

    Calculating the angle of an orthogonal triangle using the Arcsin in C#

  28. 28

    Draw a square orthogonal to a vector3 (three.js)

  29. 29

    Sorting jquery DataTables on JSON object property - using Orthogonal data

HotTag

Archive