Adding together 3D angles

  • Thread starter Twinbee
  • Start date
  • #1
117
0
Hi all,

I'm trying to 'add' two angles in 3D spherical coords. The problem is easy enough in 2D polar coords. You just add Angle A to Angle B (both in the Z plane of course). However, there doesn't seem to be an easy 3D equivalent.

Let's use this example:

Point A is:
Rot x: 0 (degrees)
Rot z: 90
Radius: 1

Point B is:
Rot x: 90
Rot z: 0
Radius: 1

In cartesian format, these points A & B translate to 0,1,0 and 0,0,1 respectively.

How do I 'add' these angles together? Any solutions I've found seem to arrive at answer that is still at Point A or Point B, rather than a different position.
 
Last edited:

Answers and Replies

  • #2
27
0
I'm trying to 'add' two angles in 3D spherical coords. ....

Okay - not much fun! Provided the Cartesian dimensions are perpendicular ("independent"), meaning for example you look first right x deg. and then, say, up y deg., and the z deg to the lower left back to your original position, the question is how to determine z from x and y only (no distances, no radii, no Cartesian methods, so no matrix/vector calculations)

Here is the equation (jotted on my envelope, so check for yourself and make sure it works)

Z = 2 * arcsin ( (sqrt[2]/2) * sqrt[ (sin^2(X/2) + sin^2(Y/2) ] )

Yep... ugly! Don't try this without a calculator...

Think of it this way - you at the top of a pyramid whose base is a rectangle and whose four inclined corner lines are all equal. From the top you can list the corner lines as a, b, c, d and all four are equal length. The angle between a and b ( written <ab) and between c and d are equal ( <ab = <cd ), let's call this angle X. Similarly, let's call angle Y = <bc = <da = <ad . Right? All these angles are going to be symmetric in two senses... The obey reflexiive (<ab = <ba ) and they are associative under addition (move up x and then to the right y is the same as to the right y and then up x).

Okay, from the top of the pyramid, what we want then is the angle Z which is none other than the diagonal angles (again identical) <ac = <bd = <ca = <db

Now, we don't know the length of the four sides a, b, c, d - but for convenience suppose they are 1. Notice then that the base of each angle will be 2 * sin ( angle/2). And so we can solve the diagonal base between the cross lines, <ac (or equivalently <bd, <ca, <db). Call that diagonal length H. Use Pythagorian to solve for H based on sin of the known angles.

Now our angle Z has a relationship with H which is

H = 2 * sin(Z/2)

Thus Z = 2 * arcsin (H/2)

Yep. Seems to be right. Remember that the two angles added have to be perpendicular in 3d space (or any higher dimensional space for that matter).
 
  • #4
27
0
You may want to have a look at rotation matrices, like on http://en.wikipedia.org/wiki/Rotation_matrix
Yes - that is the right way to do complex angle arithmetic. And the right way to program it. But it won't get you away from having to take to evaluate some ugly arcsins and stuff at the end.

Thanx for pointing this out and a rather good wikilinks article. Haven't seen some of that stuff in quite a few years.

Cheers!
 
  • #5
D H
Staff Emeritus
Science Advisor
Insights Author
15,393
685
Yes - that is the right way to do complex angle arithmetic.
That is one of many ways to deal with rotations in three space. There are a whole lot of charts on SO(3).
 
  • #6
27
0
There are a whole lot of charts on SO(3).
Indeed, many ways to skin a cat :-)
 
  • #7
chiro
Science Advisor
4,790
132
Just be aware of 'gimbal lock' if you are using composition of rotations. To avoid this you can use quaternions and if you want to use multiple rotations look into SLERPing and SQUADing.

I forget who introduced quaternions into the subject of computer graphics, but i'm sure you will be able to find a thorough article for free on the net for these topics.

Good luck!
 
  • #8
D H
Staff Emeritus
Science Advisor
Insights Author
15,393
685
There is no gimbal lock with quaternions. This is one of the big advantages of using quaternions.
 

Related Threads on Adding together 3D angles

  • Last Post
Replies
2
Views
2K
  • Last Post
Replies
2
Views
4K
  • Last Post
Replies
2
Views
31K
  • Last Post
Replies
3
Views
26K
Replies
2
Views
685
Replies
1
Views
596
Replies
6
Views
1K
Replies
12
Views
2K
Replies
3
Views
1K
Top