[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

**To**:**tech-kern%NetBSD.org@localhost****Subject**:**Re: atan2 and sqrt --> in driver****From**:**der Mouse <mouse%Rodents-Montreal.ORG@localhost>**- Date: Tue, 9 Dec 2008 14:42:45 -0500 (EST)

>> The driver is for the wii-remote, so get 1 byte for x-, y- and >> z-axis. Based on this values I will calculate the >> pitch = atan2(y, sqrt(x^2+z^2)) and yaw = atan2(z, sqrt(x^2+y^2)) Why do these have to be done in the driver, rather than userland? > Alternatively, just provide a data table, indexed by 0..255 x 0..255, > with the second operand shifted and the sqrt computed in integer > math. Search wikipedia for easy algorithms to compute isqrt. Since sqrt isn't being used in full generality, but just for hypot(), you could use a lookup table for that too. Even with cache miss effects I suspect it may be faster than integer square root code (though I'd want to benchmark before saying anything definite). /~\ The ASCII Mouse \ / Ribbon Campaign X Against HTML mouse%rodents-montreal.org@localhost / \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B

**Follow-Ups**:**Re: atan2 and sqrt --> in driver***From:*Joerg Sonnenberger

**References**:**atan2 and sqrt --> in driver***From:*Robert Fritzsche

**Re: atan2 and sqrt --> in driver***From:*Ignatios Souvatzis

**Re: atan2 and sqrt --> in driver***From:*Robert Fritzsche

**Re: atan2 and sqrt --> in driver***From:*Joerg Sonnenberger

- Prev by Date:
**Re: Proposal: B_ARRIER (addresses wapbl performance?)** - Next by Date:
**Re: Proposal: B_ARRIER (addresses wapbl performance?)** - Previous by Thread:
**Re: atan2 and sqrt --> in driver** - Next by Thread:
**Re: atan2 and sqrt --> in driver** - Indexes: