flat assembler
Message board for the users of flat assembler.
Index
> Tutorials and Examples > Azimuth To Cartesian (decimal 0..360) |
Author |
|
tthsqe 17 Nov 2023, 04:14
is this a Rube Goldburg function for calculating (90-st0) mod 360?
|
|||
17 Nov 2023, 04:14 |
|
idle 17 Nov 2023, 06:36
Az135° (South-East) ?
|
|||
17 Nov 2023, 06:36 |
|
idle 17 Nov 2023, 06:44
...
-45 [+360=315] ... omg true 😄 |
|||
17 Nov 2023, 06:44 |
|
idle 17 Nov 2023, 09:21
Code: ;2023.11.17 tthsqe mod ;2023.11.05 ;use i586 ;Cartesian Circle ° Azimuth Circle ° ;x-- x++ ;y++ y-- ; ; ; y 90° y 0° ; |.cos. | ; | . +++ |..cos.. ++ ; | sin ++ | sin +++ ; | . | . ; --------0-------x 0° --------0-------x 90° ; | | ; | | ; | | ; | | ;https://board.flatassembler.net/topic.php?t=23112 ;tthsqe "is this a Rube Goldburg function for calculating (90-st0) mod 360?" ;... haha ... omg ... elegant ... tnx!!! azimuth2cartesian: fild [.360] fxch fprem fstp st1 fisubr [.090] fldz fcomip st0,st1 jb .ret fiadd [.360] .ret: ret align 4 .360 dw 360 .090 dw 090 ;azimuth(decimal angle) -> st0 <- cartesian(decimal angle 0..360) ;flags.cf <- st0 > 180 ;st1 used ;azimuth2cartesian: ; fild [.360] ; fxch ; fprem ; fstp st1 ;mod 360 ; ; fld [.mul_pi_div_180] ; fmulp ;in rad ; ; fsincos ;azimuth x,y ; fxch ;cartesian x,y ; ; fpatan ;x,y -> rad ; ; fld [.mul_180_div_pi] ; fmulp ;deg ; ; fldz ;fpatan gives [-180..0..180] results, that is why PATRIAL; so make values absolute ie 0..360 ; fcomip st0,st1 ;i586 ; jb .ret ;0..180 ; fiadd [.360] ; ; .ret: ret ; ;align 4 ; .360 dw 360 ; .mul_pi_div_180 dt 0.0174532925199432958 ; .mul_180_div_pi dt 57.295779513082320880 |
|||
17 Nov 2023, 09:21 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.