flat assembler
Message board for the users of flat assembler.
Index
> Main > Point belong line,circle and other shapes 
Author 

Furs
If you're just doing a check, you don't need sqrt at all, just compare the squared results directly. There's no point taking the square root.
I'm sure you can do more math simplifications/factoring with that knowledge. e.g. let's say you want to check if length of vector is less than some value V. You can do: Code: x² + y² + z² < V² 

07 Sep 2022, 11:53 

Overclick
Quote:
Could you show some? 

07 Sep 2022, 13:27 

Furs
I mean in general stuff like factoring out things to reduce multiplications and so on (e.g. x*y + x*z = x*(y+z)). Nothing specialized, but without square root it's obviously far simpler to simplify things.
BTW in general when you're doing comparisons you can avoid expensive operations like square root or division by doing such transformations. For example if you have a division, just multiply both sides by the denominator and compare that. 

08 Sep 2022, 13:43 

Overclick
Quote:
Did you even look at my progress? Not you didn't. Otherwise you can see how some parameters precalculated at preprocessing stage. I don't ask here theory advices. This thread for practice, better examples, comparison.


08 Sep 2022, 14:05 

Overclick
Magic number variant:
Code: .mouse_scanner_line: subps xmm4,xword[r14+r13] mulps xmm4,xmm4 haddps xmm4,xmm0 movaps xmm5,xword[r14] movhlps xmm6,xmm5 mulps xmm5,xmm5 subps xmm4,xmm5 subps xmm4,xmm3 ; xmm3 = 0,0,1f,1f(lower) psrad xmm4,1 ; inc/ivec domain latency addps xmm4,xmm3 ; sqrtps xmm4,xmm4 haddps xmm4,xmm0 comiss xmm4,xmm6 jb .mouse_scanner_success add r14,r13 add r14,r13 cmp r14,r15 jb .mouse_scanner ret Not working at all 

08 Sep 2022, 15:27 

Overclick
Ups, my mistake
Code: psubd xmm4,xmm3 psrld xmm4,1 paddd xmm4,xmm3 But it calculates not clear enough even if weight is huge. 

08 Sep 2022, 16:01 

< Last Thread  Next Thread > 
Forum Rules:

Copyright © 19992020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.