Re: optimization of movable parts

New Message Reply Date view Thread view Subject view Author view

Lew Hitchner (hitchner++at++netcom.com)
Thu, 3 Nov 1994 15:22:54 -0800


>> Subject: Re: optimization of movable parts
>> In-Reply-To: Your message of "Thu, 03 Nov 94 13:24:19 EST."
>> Date: Thu, 03 Nov 94 14:07:57 -0800
>> From: Jim Helman <jimh++at++surreal.asd.sgi.com>
        .
        .
        .
>> For now, the most efficient way to generate the matrix is to use paper
>> and pencil to work out just what you need. The Euler*Trans is trivial
>> and certainly doesn't require a full matrix multiply even in the
>> general case.
>>
>> Euler(h,p,r):
>>
>> cr*ch - sr*sp*sh cr*sh + sr*sp*ch -sr*cp 0
>> -cp*sh cp*ch sp 0
>> sr*ch + cr*sp*sh sr*sh - cr*sp*ch cr*cp 0
>> 0 0 0 1
>>
>> Euler(h,p,r)*Trans(x,y,z)
>>
>> cr*ch - sr*sp*sh cr*sh + sr*sp*ch -sr*cp 0
>> -cp*sh cp*ch sp 0
>> sr*ch + cr*sp*sh sr*sh - cr*sp*ch cr*cp 0
>> x y z 1
>>
>> Your special case:
>>
>> Pitch(p)*Trans(x,y,z)
>>
>> 1 0 0 0
>> 0 cp sp 0
>> 0 -sp cp 0
>> x y z 1
>>
>> Trans(-x,-y,-z)*Pitch(p)*Trans(x,y,z)
>>
>> 1 0 0 0
>> 0 cp sp 0
>> 0 -sp cp 0
>> 0 y-y*cp+z*sp z-y*sp-z*cp 1
>>
>>
>> Hopefully, I got the signs right ;-).
>>
>> rgds,
>>
>> -jim helman
>>
>> jimh++at++surreal.asd.sgi.com
>> 415/390-1151

I think Jim made a great point by demonstrating the example of how
doing a little paper and pencil work (plus thinking) can make a
significant difference in performance and possibly readability of code
(if commented well). It's very tempting to assume that great general
purpose library function tools are the best way to code something.
Jim's example shows that's not always so.

I saw an example once where a programmer needed to generate his own
transformation matrix and decided the easy (lazy?) way was just to call
GL's pushmatrix(), trans(), rot(), .. whatever, getmatrix(), popmatrix().
I guessed that was probably very inefficient esp. since he had it
inside his main frame update loop (actually in a several places). Of
course, it was easier than doing the math or writing his own code for
an optimal implementation of the transformation he needed. I decided
to write my own functions to generate the matrix in software and then
run some timing comparisons, which I did on 3 different SGI platforms
(which I've forgotten now, except I know there were significant bus
differences between them and one had RE graphics another had VGX
graphics). On all machines the software version was always at least as
fast as using GL even when I stubbed out the getmatrix() (which is by
far the most time consuming of those GL calls). On one machine the GL
solution was horrible and took I think 50 times as long as the software
solution!!! That's because the getmatrix() on that machine's bus was a
real killer (on the order of 15 or 20 msec if I remember correctly --
that's mille-secs not micro-secs folks!).

Lew Hitchner
Virtual Reality and Visual Simulation Consultant
Mountain View, CA
Voice: 415-964-9425
FAX: 800-825-7689 (USA)
FAX: 510-472-6951 (international)
email: hitchner++at++netcom.com
URL: ftp://ftp.netcom.com/pub/hitchner/hitchner.html


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:50:38 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.