-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
normalize
and vlen
are slightly inconsistent.
#244
Comments
So normalize has higher precision than vlen. Why is it bad? |
Primarily because it differs from FTEQW.
Secondarily because them differing leads to people writing v / vlen(v) to
match Q3A.
…On Sun, Jan 26, 2025 at 3:45 PM uis246 ***@***.***> wrote:
So normalize has higher precision than vlen. Why is it bad?
—
Reply to this email directly, view it on GitHub
<#244 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAB5NMHA6YC524LOC5AK6QT2MVCQHAVCNFSM6AAAAABVOVHRXSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMJUGU4DINRZGQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Actually a third reason: the existing code hardcodes the assumption that |
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In FTEQW, looking at the implementations of
PF_normalize
andPF_vlen
, it seems like the following property is true:normalize(v) == v * (1.0 / vlen(v))
using the
MUL_VF
andDIV_F
instructions.Non compiler specific test case:
normalize(v) * '1 0 0' == v_x * (1.0 / vlen(v))
In DarkPlaces, this is not entirely true as the intermediate value
f
, storingvlen(v)
, is taken the reciprocal of while adouble
, not while afloat
(the square root is computed as adouble
in both engines for both builtins).I suggest changing https://github.com/DarkPlacesEngine/DarkPlaces/blob/master/prvm_cmds.c#L528 from
double f
toprvm_vec_t f
, so the two functions become consistent with each other, and to document this relationship in a comment. Also, possibly the1.0
used for computing the reciprocal also needs to be cast to(prvm_vec_t)
.The text was updated successfully, but these errors were encountered: