6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Sep 29, 2024 6:22 pm

All times are UTC




Post new topic Reply to topic  [ 22 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: C=Hacking Issue #8
PostPosted: Mon Nov 11, 2019 1:20 pm 
Offline

Joined: Tue Sep 03, 2002 12:58 pm
Posts: 325
A0CBM wrote:
I don't know how to handle the term on the right: cos(z)sin(y)sin(x), to get rid of the multiplications.


You just apply the identities twice:
Code:
cos(z)sin(y)sin(x) = cos(z)(cos(y-x) - cos(y+x))/2
                   = (cos(z)cos(y-x) - cos(z)cos(y+x))/2
                   = (cos(z+y-x) + cos(z-y+x))/4


Top
 Profile  
Reply with quote  
 Post subject: Re: C=Hacking Issue #8
PostPosted: Mon Nov 11, 2019 5:02 pm 
Offline
User avatar

Joined: Mon Apr 23, 2012 12:28 am
Posts: 760
Location: Huntsville, AL
Been following this thread.

It appears that the desire is to convert the elements of the 3D rotation matrix from products of trig functions to sums of trig functions. This appears to be motivated by a desire to reduce the number of multiplies. This is a laudable goal if not for the fact that the trig functions themselves will require many multiplications to evaluate to a desired level of accuracy.

I suspect that the processing time savings achieved by a reduction in the number of multiplies present in the 3D rotation matrix elements will be swamped by the number of additional trig functions that will be required to represent the elements as sums instead of products. Assuming that a trig function evaluation consists is 8x longer than a multiply, the evaluation of the element

cos(z)sin(y)sin(x) as [cos(a) + cos(b) - cos(c) - cos(d)] / 4

will result in 8 + 8 + 8 + 2 operations versus 8 + 8 + 8 + 8 operations (assuming divide by 4 is free). Thus, evaluation of the product form will require approximately 26 operations and the evaluation of the sum form will require approximately 32 operations. This makes the product form more efficient than the sum form.

I am not seeing a path where the number of trig function evaluations is reduced by converting from the product form to the sum form. It is an interesting exercise in using trig identities, but I am not seeing the benefit to the exercise.

Am I missing something?

_________________
Michael A.


Top
 Profile  
Reply with quote  
 Post subject: Re: C=Hacking Issue #8
PostPosted: Mon Nov 11, 2019 5:38 pm 
Offline

Joined: Mon Sep 17, 2018 2:39 am
Posts: 137
Hi!
MichaelM wrote:
Been following this thread.

It appears that the desire is to convert the elements of the 3D rotation matrix from products of trig functions to sums of trig functions. This appears to be motivated by a desire to reduce the number of multiplies. This is a laudable goal if not for the fact that the trig functions themselves will require many multiplications to evaluate to a desired level of accuracy.

I suspect that the processing time savings achieved by a reduction in the number of multiplies present in the 3D rotation matrix elements will be swamped by the number of additional trig functions that will be required to represent the elements as sums instead of products. Assuming that a trig function evaluation consists is 8x longer than a multiply, the evaluation of the element

cos(z)sin(y)sin(x) as [cos(a) + cos(b) - cos(c) - cos(d)] / 4

will result in 8 + 8 + 8 + 2 operations versus 8 + 8 + 8 + 8 operations (assuming divide by 4 is free). Thus, evaluation of the product form will require approximately 26 operations and the evaluation of the sum form will require approximately 32 operations. This makes the product form more efficient than the sum form.

I am not seeing a path where the number of trig function evaluations is reduced by converting from the product form to the sum form. It is an interesting exercise in using trig identities, but I am not seeing the benefit to the exercise.

Am I missing something?


Yes.

You can evaluate the trigonometric functions with the required precision (8 bits) with a simple table lookup, so it is faster than a standard multiplication.

Have Fun!


Top
 Profile  
Reply with quote  
 Post subject: Re: C=Hacking Issue #8
PostPosted: Mon Nov 11, 2019 5:54 pm 
Offline
User avatar

Joined: Mon Apr 23, 2012 12:28 am
Posts: 760
Location: Huntsville, AL
I guess I forgot that you're doing these transforms for a low precision application: you're not navigating to the moon and back. :D So yes, as you suggest above, table look ups for the trig functions is a great approach and the resulting simplification of the trig function evaluation would result in the sum form being much faster than the product form.

_________________
Michael A.


Top
 Profile  
Reply with quote  
 Post subject: Re: C=Hacking Issue #8
PostPosted: Tue Nov 12, 2019 7:46 pm 
Offline

Joined: Wed Nov 04, 2015 11:10 am
Posts: 51
I had a feeling there was a way and I thought about applying the identity twice, but didn't know how to approach it. That makes sense. Let's see if I can figure out any more of that article. Now I can try and figure out T1 through T10, which I'm sure has something to do with the amount of rotation. This is my own personal challenge. I appreciate everyone's help and I'm sure I'll encounter more that I need help to figure out.

Thanks.


Top
 Profile  
Reply with quote  
 Post subject: Re: C=Hacking Issue #8
PostPosted: Wed Nov 13, 2019 8:11 pm 
Offline

Joined: Wed Nov 04, 2015 11:10 am
Posts: 51
(cos(z)cos(y-x) - cos(z)cos(y+x))/2

??
cos(z)cos(y-x) = (cos(z - (y-x)) + cos(z + (y-x)))/2
cos(z)cos(y+x) = (cos(z - (y+x)) + cos(z + (y+x)))/2
??


Top
 Profile  
Reply with quote  
 Post subject: Re: C=Hacking Issue #8
PostPosted: Wed Nov 20, 2019 8:36 pm 
Offline

Joined: Wed Nov 04, 2015 11:10 am
Posts: 51
OK, I'm lost. After multiplying out rotation matrices X,Y, and Z, position 1,1 is cos(z)cos(y) which equals (cos(z-y) + cos(z+y))/2, so T1 = z-y and T2 = z+y? The article has t1 = sy - sz and t2 = sy + sz. Why are my z and y turned around?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 22 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: