#### Archived

This topic is now archived and is closed to further replies.

# Cross product in spherical coordinates

This topic is 5615 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

What's the cross product of two vectors... in spherical coordinates? I mean, is there a fast formula (like the determinant in carthesian coordinates) without converting it to carthesian, and then back to spherical? Both vectors are in the form of (distance, angle1, angle2) Thanks. [edited by - Boops on May 30, 2004 4:17:03 PM]

##### Share on other sites
i''m not thinking totally clear now so i hope this post still helps a bit.

the cross product gives a vector perpendicular to the two input vectors in a right handed way. it''s magnitude is the product of the two lenghts time the sine of the angle between them.

so you can figure out the distance from this. now you need to find the two angles that make the vector perpendicular. I''m not sure how it works with the angles

##### Share on other sites
I haven''t really tested this to see if it works, but here''s my approach off the top of my head:

Let us say we have two vectors in spherical coordinates, V1 = (r1, theta1, phi1) and V2 = (r2, theta2, phi2).

First translate the angles of V1 to be along a main axis, so that you have V1 = (r1, 0, 0). This should be simply transforming V1 by (0, -theta1, -phi1).

Do the same transformation for V2, giving (r2, theta2-theta1, phi2-phi1). Then pick one of the two angles (it shouldn''t matter which) and translate it into 0. Arbitrarily picking theta, we''ll have V2 = (r2, 0, phi2-phi1).

Now construct another vector, V3, which points perpendicular to the plane that V1 and V2 are in: V3 = (r3, 90, 0). Then reverse through the transforms we went to when getting V1 and V2 to have theta=0... so V3 should be (r3, 90+(theta2-theta1), phi1). V1 and V2 will become their original form during this transformation.

To find r3 you could do as a previous poster said and multiply the magnitude of the other two lengths times the sine of the angle between them.

Again, I haven''t tried to verify this... and someone else might already have an answer by the time I hit the reply button... but this is what I''ve got for right now. Later I''ll try to verify my answer by doing the straight conversion to cartesian (r*cos(theta)*sin(phi), r*sin(theta)*sin(phi), r*cos(phi)) and checking the cross product of that with my assumed solution.

Thanks for the interesting problem

##### Share on other sites
I think I've found it!

I found it in the appendix of a book about electromagnetic waves from Inan&Inan (who'd expect to find it there )

It can simply be done the same way as in rectangular coordinates, namely with the determinant:

      |^r   ^theta   ^phi  |AxB = |A_r  A_theta  A_phi |      |B_r  B_theta  B_phi |

However, if someone can explain me WHY this is allowed, I'd really appreciate it, because I tried to prove for myself that the result of the above determinant is the same as converting A to rectangular, then doing the determinant, and then converting it back, but I got stuck in endless goniometrical products that I can't simplify. And I really find no intuitive way to see why this is allowed. So anyone?

Thanks!

[edited by - Boops on May 31, 2004 7:56:28 AM]

##### Share on other sites
That formula clearly doesn''t work. There is no simple way to do what you want to do.

##### Share on other sites
Well, you could just transform from the spherical system into the rectangular system before performing the cross product, then transform it back at the end. They''re only 3x3 matrix transforms ( using 3D vectors ).

You have to remember that you''re unique, just like everybody else.

##### Share on other sites
quote:
Original post by python_regious
Well, you could just transform from the spherical system into the rectangular system before performing the cross product, then transform it back at the end. They're only 3x3 matrix transforms ( using 3D vectors ).

You have to remember that you're unique, just like everybody else.

But this transforming to rectangular and back costs a lot of cos and sin functions (or don't they?)

[edited by - Boops on May 31, 2004 9:46:49 AM]

##### Share on other sites
Well it seems like that electromagnetism book just substituted spherical 3d coordinates in for rectangular (prismical? ) 3d coordinates. Shrug it works for a lot of other things (for example omega2 = omega1 + alpha * t is equivalent to v2 = v1 + at BUT they do not calculate the same thing). Maybe that's some sort of crazy angular cross product..?

Sigh who knows. If nobody can completely answer this guy's poor question I'll work through to a solution. A little math never hurt me I guess.

[edited by - uber_n00b on May 31, 2004 10:35:46 AM]

##### Share on other sites
Hmmm... Well I''ve looked through two of my books ( Elements of Electromagnetics, and Microwave Engineering ) which are super-heavy in vector maths, and found no references to a derived formula for a vector product in spherical coordinates.

Ah well, I may try to derive something if I get bored, and no-one else comes up with anything.

You have to remember that you''re unique, just like everybody else.

##### Share on other sites
quote:
Original post by Boops
But this transforming to rectangular and back costs a lot of cos and sin functions (or don''t they?)

cos and sin functions arn''t as evil as people think. If you code isn''t that time-critical i wouldn''t worry about it and just go ahead with the converting.

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 18
• 35
• 9
• 16
• 22