[Bf-python] Good old euler problem

Joseph Gilbert jgilbert at tigr.ORG
Thu Feb 22 19:04:09 CET 2007


Converting Euler to radians so that it is in line with python's math  
library is a great idea. However, it's internal functions will then expect  
radians only. Therefore, this just moves the ball instead of fixing the  
problem.

Example:
myeuler.Unique()

This expect degrees to be loaded into the euler.  Load it with radians and  
it will calculate the wrong answer. Most likely this is also the case with  
Euler.toMatrix(), Euler.toQuat().
The Euler needs to define how it is constructed so we know we are working  
with radians or degrees.

e = Euler(1,2,3)
m = Euler.toMatrix()

was e in radians or degrees? The calculation of the matrix probably  
depends on knowing this.
I would not like to add a caveat to the Euler module saying "Please use  
radians or this class will give you bad answers".

Splitting out the Euler class into a Radians and Degrees version with a  
conversion between the two seems like the simplest solution.

On Wed, 21 Feb 2007 12:40:27 -0500, Stephen Swaney  
<sswaney at centurytel.net> wrote:

> n Wed, Feb 21, 2007 at 08:29:42AM -0800, Martin Poirier wrote:
>> No constants please.
>>
>> If people want to multiply by a constant, they can
>> define it themselves.
>>
>> If we have to provide anything, it should be a
>> function.
>
> The Python math module already has degree() and radian()
> functions for conversion.
>
> The idea of having an internal state flag in Euler for setting
> units is clever, but seems overly complicated.  If passed as an
> argument, you would need to test the Euler obj before you could use
> it.  It also becomes One More Thing to keep track of when coding.
>
> You could hide some complexity by creating EulerDegree and EulerRadian
> wrapper classes, but then we have 3 classes to manage  rather than one
> and we are getting complicated again.
>
> I think the simplest, most consistant solution is to use radians
> everywhere.
>
> If we need to convert to/from degrees for presentation layer things
> like a GUI, we can provide our own convenience methods and
> constructors in addition to the degrees() and radians() in the math
> module.
>



-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/



More information about the Bf-python mailing list