In article <1993Mar5.105326.22133@metapro.DIALix.oz.au> bernie@metapro.DIALix.oz.au (Bernd Felsche) writes: >In <39610@cbmvax.cbm.commodore.com> > >If at all possible, don't use trig functions at all. > >Most graphics applications are accurate enough with the first 2 >or 3 terms of an equivalent Taylor series. Error is usually of >the order of 1:1000. > The following code is what I use. It's accurate enough for computing texture map coordinates in my ray-tracer: acos:: ; input d0=cos output d0=acos(d0) 1 -> 0 0 > .25 -1 > .5 ; trashes d1/d2,a0 tst.w d0 bmi.s negacos posacos: move d0,d2 and.w #$001f,d2 lsr #5,d0 add d0,d0 lea acos_tbl(pc),a0 move 2(a0,d0.w),d1 move 0(a0,d0.w),d0 sub d0,d1 muls d2,d1 asr.w #5,d1 add d1,d0 rts negacos: neg.w d0 bsr.s posacos neg.w d0 add.w #$7ffe,d0 ; acos(-x) = .5-acos(x) rts and here's the boring part: acos_tbl: dc.w $3fff dc.w $3ff5 dc.w $3feb dc.w $3fe1 dc.w $3fd7 dc.w $3fcd dc.w $3fc2 dc.w $3fb8 dc.w $3fae dc.w $3fa4 dc.w $3f9a dc.w $3f8f dc.w $3f85 dc.w $3f7b dc.w $3f71 dc.w $3f67 dc.w $3f5d dc.w $3f52 dc.w $3f48 dc.w $3f3e dc.w $3f34 dc.w $3f2a dc.w $3f1f dc.w $3f15 dc.w $3f0b dc.w $3f01 dc.w $3ef7 dc.w $3eec dc.w $3ee2 dc.w $3ed8 dc.w $3ece dc.w $3ec4 dc.w $3eb9 dc.w $3eaf dc.w $3ea5 dc.w $3e9b dc.w $3e91 dc.w $3e87 dc.w $3e7c dc.w $3e72 dc.w $3e68 dc.w $3e5e dc.w $3e54 dc.w $3e49 dc.w $3e3f dc.w $3e35 dc.w $3e2b dc.w $3e21 dc.w $3e16 dc.w $3e0c dc.w $3e02 dc.w $3df8 dc.w $3dee dc.w $3de3 dc.w $3dd9 dc.w $3dcf dc.w $3dc5 dc.w $3dbb dc.w $3db0 dc.w $3da6 dc.w $3d9c dc.w $3d92 dc.w $3d88 dc.w $3d7d dc.w $3d73 dc.w $3d69 dc.w $3d5f dc.w $3d55 dc.w $3d4a dc.w $3d40 dc.w $3d36 dc.w $3d2c dc.w $3d22 dc.w $3d17 dc.w $3d0d dc.w $3d03 dc.w $3cf9 dc.w $3cee dc.w $3ce4 dc.w $3cda dc.w $3cd0 dc.w $3cc6 dc.w $3cbb dc.w $3cb1 dc.w $3ca7 dc.w $3c9d dc.w $3c92 dc.w $3c88 dc.w $3c7e dc.w $3c74 dc.w $3c6a dc.w $3c5f dc.w $3c55 dc.w $3c4b dc.w $3c41 dc.w $3c36 dc.w $3c2c dc.w $3c22 dc.w $3c18 dc.w $3c0e dc.w $3c03 dc.w $3bf9 dc.w $3bef dc.w $3be5 dc.w $3bda dc.w $3bd0 dc.w $3bc6 dc.w $3bbc dc.w $3bb1 dc.w $3ba7 dc.w $3b9d dc.w $3b93 dc.w $3b88 dc.w $3b7e dc.w $3b74 dc.w $3b6a dc.w $3b5f dc.w $3b55 dc.w $3b4b dc.w $3b41 dc.w $3b36 dc.w $3b2c dc.w $3b22 dc.w $3b18 dc.w $3b0d dc.w $3b03 dc.w $3af9 dc.w $3aef dc.w $3ae4 dc.w $3ada dc.w $3ad0 dc.w $3ac5 dc.w $3abb dc.w $3ab1 dc.w $3aa7 dc.w $3a9c dc.w $3a92 dc.w $3a88 dc.w $3a7e dc.w $3a73 dc.w $3a69 dc.w $3a5f dc.w $3a54 dc.w $3a4a dc.w $3a40 dc.w $3a36 dc.w $3a2b dc.w $3a21 dc.w $3a17 dc.w $3a0c dc.w $3a02 dc.w $39f8 dc.w $39ed dc.w $39e3 dc.w $39d9 dc.w $39cf dc.w $39c4 dc.w $39ba dc.w $39b0 dc.w $39a5 dc.w $399b dc.w $3991 dc.w $3986 dc.w $397c dc.w $3972 dc.w $3967 dc.w $395d dc.w $3953 dc.w $3948 dc.w $393e dc.w $3934 dc.w $392a dc.w $391f dc.w $3915 dc.w $390b dc.w $3900 dc.w $38f6 dc.w $38eb dc.w $38e1 dc.w $38d7 dc.w $38cc dc.w $38c2 dc.w $38b8 dc.w $38ad dc.w $38a3 dc.w $3899 dc.w $388e dc.w $3884 dc.w $387a dc.w $386f dc.w $3865 dc.w $385b dc.w $3850 dc.w $3846 dc.w $383b dc.w $3831 dc.w $3827 dc.w $381c dc.w $3812 dc.w $3808 dc.w $37fd dc.w $37f3 dc.w $37e8 dc.w $37de dc.w $37d4 dc.w $37c9 dc.w $37bf dc.w $37b4 dc.w $37aa dc.w $37a0 dc.w $3795 dc.w $378b dc.w $3780 dc.w $3776 dc.w $376c dc.w $3761 dc.w $3757 dc.w $374c dc.w $3742 dc.w $3737 dc.w $372d dc.w $3723 dc.w $3718 dc.w $370e dc.w $3703 dc.w $36f9 dc.w $36ee dc.w $36e4 dc.w $36d9 dc.w $36cf dc.w $36c5 dc.w $36ba dc.w $36b0 dc.w $36a5 dc.w $369b dc.w $3690 dc.w $3686 dc.w $367b dc.w $3671 dc.w $3666 dc.w $365c dc.w $3651 dc.w $3647 dc.w $363c dc.w $3632 dc.w $3628 dc.w $361d dc.w $3613 dc.w $3608 dc.w $35fe dc.w $35f3 dc.w $35e9 dc.w $35de dc.w $35d3 dc.w $35c9 dc.w $35be dc.w $35b4 dc.w $35a9 dc.w $359f dc.w $3594 dc.w $358a dc.w $357f dc.w $3575 dc.w $356a dc.w $3560 dc.w $3555 dc.w $354b dc.w $3540 dc.w $3536 dc.w $352b dc.w $3520 dc.w $3516 dc.w $350b dc.w $3501 dc.w $34f6 dc.w $34ec dc.w $34e1 dc.w $34d6 dc.w $34cc dc.w $34c1 dc.w $34b7 dc.w $34ac dc.w $34a1 dc.w $3497 dc.w $348c dc.w $3482 dc.w $3477 dc.w $346c dc.w $3462 dc.w $3457 dc.w $344d dc.w $3442 dc.w $3437 dc.w $342d dc.w $3422 dc.w $3417 dc.w $340d dc.w $3402 dc.w $33f8 dc.w $33ed dc.w $33e2 dc.w $33d8 dc.w $33cd dc.w $33c2 dc.w $33b8 dc.w $33ad dc.w $33a2 dc.w $3398 dc.w $338d dc.w $3382 dc.w $3378 dc.w $336d dc.w $3362 dc.w $3357 dc.w $334d dc.w $3342 dc.w $3337 dc.w $332d dc.w $3322 dc.w $3317 dc.w $330c dc.w $3302 dc.w $32f7 dc.w $32ec dc.w $32e2 dc.w $32d7 dc.w $32cc dc.w $32c1 dc.w $32b7 dc.w $32ac dc.w $32a1 dc.w $3296 dc.w $328c dc.w $3281 dc.w $3276 dc.w $326b dc.w $3260 dc.w $3256 dc.w $324b dc.w $3240 dc.w $3235 dc.w $322a dc.w $3220 dc.w $3215 dc.w $320a dc.w $31ff dc.w $31f4 dc.w $31ea dc.w $31df dc.w $31d4 dc.w $31c9 dc.w $31be dc.w $31b3 dc.w $31a9 dc.w $319e dc.w $3193 dc.w $3188 dc.w $317d dc.w $3172 dc.w $3167 dc.w $315c dc.w $3152 dc.w $3147 dc.w $313c dc.w $3131 dc.w $3126 dc.w $311b dc.w $3110 dc.w $3105 dc.w $30fa dc.w $30ef dc.w $30e5 dc.w $30da dc.w $30cf dc.w $30c4 dc.w $30b9 dc.w $30ae dc.w $30a3 dc.w $3098 dc.w $308d dc.w $3082 dc.w $3077 dc.w $306c dc.w $3061 dc.w $3056 dc.w $304b dc.w $3040 dc.w $3035 dc.w $302a dc.w $301f dc.w $3014 dc.w $3009 dc.w $2ffe dc.w $2ff3 dc.w $2fe8 dc.w $2fdd dc.w $2fd2 dc.w $2fc7 dc.w $2fbc dc.w $2fb1 dc.w $2fa6 dc.w $2f9b dc.w $2f90 dc.w $2f84 dc.w $2f79 dc.w $2f6e dc.w $2f63 dc.w $2f58 dc.w $2f4d dc.w $2f42 dc.w $2f37 dc.w $2f2c dc.w $2f21 dc.w $2f15 dc.w $2f0a dc.w $2eff dc.w $2ef4 dc.w $2ee9 dc.w $2ede dc.w $2ed3 dc.w $2ec7 dc.w $2ebc dc.w $2eb1 dc.w $2ea6 dc.w $2e9b dc.w $2e8f dc.w $2e84 dc.w $2e79 dc.w $2e6e dc.w $2e63 dc.w $2e57 dc.w $2e4c dc.w $2e41 dc.w $2e36 dc.w $2e2a dc.w $2e1f dc.w $2e14 dc.w $2e09 dc.w $2dfd dc.w $2df2 dc.w $2de7 dc.w $2ddc dc.w $2dd0 dc.w $2dc5 dc.w $2dba dc.w $2dae dc.w $2da3 dc.w $2d98 dc.w $2d8c dc.w $2d81 dc.w $2d76 dc.w $2d6a dc.w $2d5f dc.w $2d54 dc.w $2d48 dc.w $2d3d dc.w $2d32 dc.w $2d26 dc.w $2d1b dc.w $2d0f dc.w $2d04 dc.w $2cf9 dc.w $2ced dc.w $2ce2 dc.w $2cd6 dc.w $2ccb dc.w $2cc0 dc.w $2cb4 dc.w $2ca9 dc.w $2c9d dc.w $2c92 dc.w $2c86 dc.w $2c7b dc.w $2c6f dc.w $2c64 dc.w $2c58 dc.w $2c4d dc.w $2c41 dc.w $2c36 dc.w $2c2a dc.w $2c1f dc.w $2c13 dc.w $2c08 dc.w $2bfc dc.w $2bf1 dc.w $2be5 dc.w $2bd9 dc.w $2bce dc.w $2bc2 dc.w $2bb7 dc.w $2bab dc.w $2ba0 dc.w $2b94 dc.w $2b88 dc.w $2b7d dc.w $2b71 dc.w $2b65 dc.w $2b5a dc.w $2b4e dc.w $2b42 dc.w $2b37 dc.w $2b2b dc.w $2b1f dc.w $2b14 dc.w $2b08 dc.w $2afc dc.w $2af1 dc.w $2ae5 dc.w $2ad9 dc.w $2acd dc.w $2ac2 dc.w $2ab6 dc.w $2aaa dc.w $2a9e dc.w $2a93 dc.w $2a87 dc.w $2a7b dc.w $2a6f dc.w $2a63 dc.w $2a58 dc.w $2a4c dc.w $2a40 dc.w $2a34 dc.w $2a28 dc.w $2a1c dc.w $2a11 dc.w $2a05 dc.w $29f9 dc.w $29ed dc.w $29e1 dc.w $29d5 dc.w $29c9 dc.w $29bd dc.w $29b1 dc.w $29a6 dc.w $299a dc.w $298e dc.w $2982 dc.w $2976 dc.w $296a dc.w $295e dc.w $2952 dc.w $2946 dc.w $293a dc.w $292e dc.w $2922 dc.w $2916 dc.w $290a dc.w $28fe dc.w $28f1 dc.w $28e5 dc.w $28d9 dc.w $28cd dc.w $28c1 dc.w $28b5 dc.w $28a9 dc.w $289d dc.w $2891 dc.w $2885 dc.w $2878 dc.w $286c dc.w $2860 dc.w $2854 dc.w $2848 dc.w $283b dc.w $282f dc.w $2823 dc.w $2817 dc.w $280b dc.w $27fe dc.w $27f2 dc.w $27e6 dc.w $27da dc.w $27cd dc.w $27c1 dc.w $27b5 dc.w $27a8 dc.w $279c dc.w $2790 dc.w $2783 dc.w $2777 dc.w $276b dc.w $275e dc.w $2752 dc.w $2745 dc.w $2739 dc.w $272d dc.w $2720 dc.w $2714 dc.w $2707 dc.w $26fb dc.w $26ee dc.w $26e2 dc.w $26d5 dc.w $26c9 dc.w $26bc dc.w $26b0 dc.w $26a3 dc.w $2697 dc.w $268a dc.w $267e dc.w $2671 dc.w $2665 dc.w $2658 dc.w $264b dc.w $263f dc.w $2632 dc.w $2625 dc.w $2619 dc.w $260c dc.w $25ff dc.w $25f3 dc.w $25e6 dc.w $25d9 dc.w $25cd dc.w $25c0 dc.w $25b3 dc.w $25a6 dc.w $259a dc.w $258d dc.w $2580 dc.w $2573 dc.w $2566 dc.w $255a dc.w $254d dc.w $2540 dc.w $2533 dc.w $2526 dc.w $2519 dc.w $250c dc.w $24ff dc.w $24f3 dc.w $24e6 dc.w $24d9 dc.w $24cc dc.w $24bf dc.w $24b2 dc.w $24a5 dc.w $2498 dc.w $248b dc.w $247e dc.w $2471 dc.w $2463 dc.w $2456 dc.w $2449 dc.w $243c dc.w $242f dc.w $2422 dc.w $2415 dc.w $2408 dc.w $23fa dc.w $23ed dc.w $23e0 dc.w $23d3 dc.w $23c6 dc.w $23b8 dc.w $23ab dc.w $239e dc.w $2391 dc.w $2383 dc.w $2376 dc.w $2369 dc.w $235b dc.w $234e dc.w $2341 dc.w $2333 dc.w $2326 dc.w $2318 dc.w $230b dc.w $22fd dc.w $22f0 dc.w $22e3 dc.w $22d5 dc.w $22c8 dc.w $22ba dc.w $22ac dc.w $229f dc.w $2291 dc.w $2284 dc.w $2276 dc.w $2269 dc.w $225b dc.w $224d dc.w $2240 dc.w $2232 dc.w $2224 dc.w $2217 dc.w $2209 dc.w $21fb dc.w $21ed dc.w $21e0 dc.w $21d2 dc.w $21c4 dc.w $21b6 dc.w $21a8 dc.w $219a dc.w $218c dc.w $217f dc.w $2171 dc.w $2163 dc.w $2155 dc.w $2147 dc.w $2139 dc.w $212b dc.w $211d dc.w $210f dc.w $2101 dc.w $20f3 dc.w $20e5 dc.w $20d6 dc.w $20c8 dc.w $20ba dc.w $20ac dc.w $209e dc.w $2090 dc.w $2081 dc.w $2073 dc.w $2065 dc.w $2057 dc.w $2048 dc.w $203a dc.w $202c dc.w $201d dc.w $200f dc.w $2001 dc.w $1ff2 dc.w $1fe4 dc.w $1fd5 dc.w $1fc7 dc.w $1fb8 dc.w $1faa dc.w $1f9b dc.w $1f8d dc.w $1f7e dc.w $1f70 dc.w $1f61 dc.w $1f52 dc.w $1f44 dc.w $1f35 dc.w $1f26 dc.w $1f18 dc.w $1f09 dc.w $1efa dc.w $1eeb dc.w $1edc dc.w $1ece dc.w $1ebf dc.w $1eb0 dc.w $1ea1 dc.w $1e92 dc.w $1e83 dc.w $1e74 dc.w $1e65 dc.w $1e56 dc.w $1e47 dc.w $1e38 dc.w $1e29 dc.w $1e1a dc.w $1e0b dc.w $1dfb dc.w $1dec dc.w $1ddd dc.w $1dce dc.w $1dbf dc.w $1daf dc.w $1da0 dc.w $1d91 dc.w $1d81 dc.w $1d72 dc.w $1d62 dc.w $1d53 dc.w $1d44 dc.w $1d34 dc.w $1d25 dc.w $1d15 dc.w $1d05 dc.w $1cf6 dc.w $1ce6 dc.w $1cd7 dc.w $1cc7 dc.w $1cb7 dc.w $1ca7 dc.w $1c98 dc.w $1c88 dc.w $1c78 dc.w $1c68 dc.w $1c58 dc.w $1c48 dc.w $1c39 dc.w $1c29 dc.w $1c19 dc.w $1c09 dc.w $1bf8 dc.w $1be8 dc.w $1bd8 dc.w $1bc8 dc.w $1bb8 dc.w $1ba8 dc.w $1b98 dc.w $1b87 dc.w $1b77 dc.w $1b67 dc.w $1b56 dc.w $1b46 dc.w $1b35 dc.w $1b25 dc.w $1b14 dc.w $1b04 dc.w $1af3 dc.w $1ae3 dc.w $1ad2 dc.w $1ac1 dc.w $1ab1 dc.w $1aa0 dc.w $1a8f dc.w $1a7e dc.w $1a6e dc.w $1a5d dc.w $1a4c dc.w $1a3b dc.w $1a2a dc.w $1a19 dc.w $1a08 dc.w $19f7 dc.w $19e6 dc.w $19d4 dc.w $19c3 dc.w $19b2 dc.w $19a1 dc.w $198f dc.w $197e dc.w $196c dc.w $195b dc.w $194a dc.w $1938 dc.w $1926 dc.w $1915 dc.w $1903 dc.w $18f1 dc.w $18e0 dc.w $18ce dc.w $18bc dc.w $18aa dc.w $1898 dc.w $1886 dc.w $1874 dc.w $1862 dc.w $1850 dc.w $183e dc.w $182c dc.w $181a dc.w $1807 dc.w $17f5 dc.w $17e3 dc.w $17d0 dc.w $17be dc.w $17ab dc.w $1799 dc.w $1786 dc.w $1773 dc.w $1760 dc.w $174e dc.w $173b dc.w $1728 dc.w $1715 dc.w $1702 dc.w $16ef dc.w $16dc dc.w $16c9 dc.w $16b5 dc.w $16a2 dc.w $168f dc.w $167b dc.w $1668 dc.w $1654 dc.w $1641 dc.w $162d dc.w $1619 dc.w $1606 dc.w $15f2 dc.w $15de dc.w $15ca dc.w $15b6 dc.w $15a2 dc.w $158e dc.w $157a dc.w $1565 dc.w $1551 dc.w $153d dc.w $1528 dc.w $1513 dc.w $14ff dc.w $14ea dc.w $14d5 dc.w $14c1 dc.w $14ac dc.w $1497 dc.w $1482 dc.w $146c dc.w $1457 dc.w $1442 dc.w $142c dc.w $1417 dc.w $1401 dc.w $13ec dc.w $13d6 dc.w $13c0 dc.w $13aa dc.w $1394 dc.w $137e dc.w $1368 dc.w $1352 dc.w $133b dc.w $1325 dc.w $130e dc.w $12f8 dc.w $12e1 dc.w $12ca dc.w $12b3 dc.w $129c dc.w $1285 dc.w $126e dc.w $1257 dc.w $123f dc.w $1227 dc.w $1210 dc.w $11f8 dc.w $11e0 dc.w $11c8 dc.w $11b0 dc.w $1198 dc.w $117f dc.w $1167 dc.w $114e dc.w $1135 dc.w $111c dc.w $1103 dc.w $10ea dc.w $10d1 dc.w $10b7 dc.w $109e dc.w $1084 dc.w $106a dc.w $1050 dc.w $1036 dc.w $101b dc.w $1001 dc.w $0fe6 dc.w $0fcb dc.w $0fb0 dc.w $0f95 dc.w $0f7a dc.w $0f5e dc.w $0f42 dc.w $0f26 dc.w $0f0a dc.w $0eee dc.w $0ed2 dc.w $0eb5 dc.w $0e98 dc.w $0e7b dc.w $0e5d dc.w $0e40 dc.w $0e22 dc.w $0e04 dc.w $0de5 dc.w $0dc7 dc.w $0da8 dc.w $0d89 dc.w $0d6a dc.w $0d4a dc.w $0d2a dc.w $0d0a dc.w $0ce9 dc.w $0cc8 dc.w $0ca7 dc.w $0c86 dc.w $0c64 dc.w $0c42 dc.w $0c1f dc.w $0bfc dc.w $0bd9 dc.w $0bb5 dc.w $0b91 dc.w $0b6c dc.w $0b47 dc.w $0b22 dc.w $0afc dc.w $0ad5 dc.w $0aae dc.w $0a87 dc.w $0a5f dc.w $0a36 dc.w $0a0d dc.w $09e2 dc.w $09b8 dc.w $098c dc.w $0960 dc.w $0933 dc.w $0905 dc.w $08d6 dc.w $08a6 dc.w $0875 dc.w $0844 dc.w $0810 dc.w $07dc dc.w $07a6 dc.w $076f dc.w $0736 dc.w $06fb dc.w $06be dc.w $067f dc.w $063e dc.w $05fa dc.w $05b2 dc.w $0567 dc.w $0518 dc.w $04c4 dc.w $0469 dc.w $0407 dc.w $039a dc.w $031e dc.w $028c dc.w $01cc dc.w $0000 -- *-------------------------------------------*---------------------------* |Chris Green - Graphics Software Engineer - chrisg@commodore.COM f | Commodore-Amiga - uunet!cbmvax!chrisg n |My opinions are my own, and do not - icantforgettheimpression o