Docs: note that normalize_v# functions zero out input containing nan
This commit is contained in:
parent
92f4abc37f
commit
8fa05efe0a
|
@ -1145,6 +1145,9 @@ MINLINE float len_v3v3(const float a[3], const float b[3])
|
|||
return len_v3(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* \note any vectors containing `nan` will be zeroed out.
|
||||
*/
|
||||
MINLINE float normalize_v2_v2_length(float r[2], const float a[2], const float unit_length)
|
||||
{
|
||||
float d = dot_v2v2(a, a);
|
||||
|
@ -1154,6 +1157,7 @@ MINLINE float normalize_v2_v2_length(float r[2], const float a[2], const float u
|
|||
mul_v2_v2fl(r, a, unit_length / d);
|
||||
}
|
||||
else {
|
||||
/* Either the vector is small or one of it's values contained `nan`. */
|
||||
zero_v2(r);
|
||||
d = 0.0f;
|
||||
}
|
||||
|
@ -1175,17 +1179,20 @@ MINLINE float normalize_v2_length(float n[2], const float unit_length)
|
|||
return normalize_v2_v2_length(n, n, unit_length);
|
||||
}
|
||||
|
||||
/**
|
||||
* \note any vectors containing `nan` will be zeroed out.
|
||||
*/
|
||||
MINLINE float normalize_v3_v3_length(float r[3], const float a[3], const float unit_length)
|
||||
{
|
||||
float d = dot_v3v3(a, a);
|
||||
|
||||
/* a larger value causes normalize errors in a
|
||||
* scaled down models with camera extreme close */
|
||||
/* A larger value causes normalize errors in a scaled down models with camera extreme close. */
|
||||
if (d > 1.0e-35f) {
|
||||
d = sqrtf(d);
|
||||
mul_v3_v3fl(r, a, unit_length / d);
|
||||
}
|
||||
else {
|
||||
/* Either the vector is small or one of it's values contained `nan`. */
|
||||
zero_v3(r);
|
||||
d = 0.0f;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue