sfs-python icon indicating copy to clipboard operation
sfs-python copied to clipboard

Naming: Clarify what "normalization" means

Open mgeier opened this issue 8 years ago • 9 comments

Currently we have sfs.util.normalize() and sfs.util.normal_vector() which do very different things. This might be confusing.

mgeier avatar Dec 11 '16 20:12 mgeier

The function sfs.util.normal_vector() takes a vector and normalizes it. We could therefore rename it to sfs.util.normalize_vector().

spors avatar Dec 12 '16 10:12 spors

Alternatively we could get rid of sfs.util.normal_vector(). It seems it is used only in sfs.util.rotation_matrix().

trettberg avatar Dec 14 '16 10:12 trettberg

@trettberg That may be its only use for now, but we should call it wherever normal vectors are passed to functions, see #20.

mgeier avatar Dec 16 '16 16:12 mgeier

I just stumbled across this problem. I'll need a sfs.util.normalize_vector(). Please do not remove, but rename ;)

chris-hld avatar Dec 16 '16 18:12 chris-hld

In #34 I introduced now util.normalize_vector(). I'm still not completely sure if this is the best name. Most of the time we are dealing with directions when we are using unit vectors. We have also util.direction_vector(alpha, beta=np.pi/2) and I could also imagine util.direction_vector(point1, point2). Maybe there is a way to combine all this?

hagenw avatar Dec 21 '16 15:12 hagenw

util.direction_vector(point1, point2) would be very handy, if not necessary. Or I would introduce an optional "base" to normalize_vector() . The default would be 0.

Please have a look at this:

xs = np.r_[0.5, 0.5, 0] # position of virtual source xref = np.r_[0, 0, 0] nfs = sfs.util.normalize_vector(xref - xs)

For subtracting, I first have to create an array, which is not consistent with our array_like structure elsewhere. But actually I just have to specify the base of the vector to be xs.

Should we rather introduce a new function, or extend the existing?

chris-hld avatar Dec 21 '16 16:12 chris-hld

I agree that we need a way to subtract vectors (without having a vector data type), but I'm not sure if it is obvious enough what a function named direction_vector() with two points as input would do.

Does it just subtract or also normalize?

Also, Python doesn't do function overloading, so having the same direction_vector() function with alpha/beta and point1/point2 is a bit awkward.

The concept of a "base" in this context is new to me, I'm not sure if that's easy enough to understand.

What we need is something similar to a "look at" function. Just some random links: https://docs.unity3d.com/ScriptReference/Transform.LookAt.html https://keithmaggio.wordpress.com/2011/01/19/math-magician-lookat-algorithm/

At some point, we might need a "up" vector, too. So it's probably good to think about that as well.

mgeier avatar Dec 21 '16 17:12 mgeier

Sorry, I think the accurate term is "initial point" of a vector. Typically our direction vectors are normalized.

chris-hld avatar Dec 21 '16 18:12 chris-hld

I still think it's a bit awkward to have this as an optional argument of normalize_vector().

Probably we shouldn't even use the word "vector", but instead something with the word "orientation" or "direction"?

I've created a separate issue for "view" and "up" vectors, which is probably related to this issue: #36.

mgeier avatar Jan 02 '17 20:01 mgeier